client = new Client(['base_uri' => $this->baseUri]); } public function put($key, $value) { $this->client->post('kv/put', [ 'json' => [ 'key' => base64_encode($key), 'value' => base64_encode($value), ], ]); } public function get($key) { $response = $this->client->post('kv/range', [ 'json' => [ 'key' => base64_encode($key), ], ]); return json_decode($response->getBody()->getContents(), true); } public function deleteByPrefix($prefix) { // Encode the prefix $encodedPrefix = base64_encode($prefix); // Calculate the range end by incrementing the last character $lastChar = $prefix[strlen($prefix) - 1]; $rangeEnd = $prefix . chr(ord($lastChar) + 1); $encodedRangeEnd = base64_encode($rangeEnd); // Send the delete request $this->client->post('kv/deletion_range', [ 'json' => [ 'key' => $encodedPrefix, 'range_end' => $encodedRangeEnd, ], ]); } }