bytekv
v1.0.0
Published
A JavaScript client for ByteKV server (TCP + RESP)
Readme
ByteKV
A lightweight JavaScript client for ByteKV — a Redis-like in-memory key-value server over TCP using RESP protocol.
Supports basic commands like SET, GET, DEL, and PING. Can be extended to EXPIRE, TTL, PUBLISH, etc.
Installation
npm install bytekvUsage
import { ByteKVClient } from "bytekv";
const client = new ByteKVClient("127.0.0.1", 6379);
(async () => {
await client.set("foo", "bar");
const value = await client.get("foo");
console.log(value); // "bar"
await client.del("foo");
const ping = await client.ping();
console.log(ping); // "PONG"
})();API
new ByteKVClient(host, port)Creates a new client instance. Defaults: host = "127.0.0.1", port = 6379.
Commands
set(key, value)→ Sets a key-value pair.get(key)→ Gets the value of a key. Returnsnullif missing.del(key)→ Deletes a key. Returns1if deleted,0if not found.ping()→ Pings the server. Returns"PONG".
Example with TTL (optional)
await client.sendCommand(["SET", "foo", "bar", "10"]); // TTL in secondsLicense
MIT
