A lightweight Redis-like key-value database implementation with a Rust backend and Node.js client.
Build and run the server:
cargo build
cargo run
The server will start listening on localhost:2006
.
- Run the client:
node index.js
# bun index.js
(async () => {
const client = new RedisClient();
// set value
const a = await client.set('username', "John", 60);
console.log("SET:", a);
// get value
const b = await client.get('username');
console.log("GET:", b);
// get all values
const c = await client.getAll();
console.log("GET_ALL:", c);
// delete the key
const d = await client.delete('username');
console.log("DELETE:", d);
process.exit(0)
})();
connect()
: connect to the serverset(key, value, ttl)
: store a value with optional TTL in secondsget(key)
: retrieve a value by keygetAll()
: retrieve all stored valuesdelete(key)
: delete a key-value pair
Feel free to submit issues and enhancement requests!