dicedb
v1.0.6
Published
A JavaScript client for DiceDB.
Downloads
21
Maintainers
Readme
DiceDB Client
DiceDB Client is a Node.js client for interacting with DiceDB, an in-memory real-time database. This client allows you to connect to a DiceDB server, send commands, and retrieve responses.
The easiest way to get started with DiceDB is using Docker by running the following command:
docker run dicedb/dicedb
You can install the DiceDB client using npm:
npm install dicedb
Installation and Commands
For any installation instructions and command usage, check the official DiceDB documentation: DiceDB Installation Guide
Connecting to DiceDB and Using GET/SET Commands
The following example demonstrates how to connect to a DiceDB server and use the SET
and GET
commands to store and retrieve a value.
Example Code
const DiceDBClient = require('dicedb')
// (default: host=127.0.0.1, port=7379)
const client = new DiceDBClient();
// Connect to the DiceDB server
client.connect(() => {
console.log('Connected to DiceDB');
client.SET("MY_KEY","Golchi")
.then(response => {
console.log('Set Response:', response);
// Now, let's get the value we just set
return client.GET("MY_KEY");
})
.then(response => {
console.log('Get Response:', response);
})
.catch(err => {
console.error('Error:', err);
});
});