Simple Hello, World!
Before we start with Hello, World program for DiceDB, make sure you have
- a running instance of DiceDB
- installed DiceDB CLI
You can follow the steps mentioned in the installation guide to wrap up the installation.
Starting DiceDB
Once the DiceDB server starts, you will see output similar to this
Starting the DiceDB CLI
Open your terminal or command prompt and fire the following command
This command launches the DiceDB CLI REPL, presenting you with a prompt similar to this
This indicates that you’re connected to the default DiceDB instance on your local machine on port 7379.
Storing Data: The SET Command
Let’s store <k1, v1>
in DiceDB. We’ll use the SET
command, which is responsible for storing a string value under a specified key.
Here’s a breakdown of what happened:
SET
: This is the DiceDB command to store a value.k1
: This is the key we’re assigning to the value.v1
: This is the actual value we want to store. It’s a simple string in this case.OK
: DiceDB’s response indicating successful storage.
Retrieving Data: The GET Command
Now, let’s fetch the stored value using the GET
command.
The GET
command retrieves the value associated with the specified key. In this case, we retrieved the “v1” message we stored earlier.
Conclusion
This is just the tip of the iceberg when it comes to DiceDB. We’ve covered the basics of connecting to a DiceDB instance, storing a simple string, and retrieving it. The true power of DiceDB lies in its ability to intuitively build realtime reactive applications like leaderboards, handle complex data structures and perform operations efficiently.