Hello, World - Simple
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
Section titled “Starting DiceDB”Once the DiceDB server starts, you will see output similar to this
██████╗ ██╗ ██████╗███████╗██████╗ ██████╗ ██╔══██╗██║██╔════╝██╔════╝██╔══██╗██╔══██╗ ██║ ██║██║██║ █████╗ ██║ ██║██████╔╝ ██║ ██║██║██║ ██╔══╝ ██║ ██║██╔══██╗ ██████╔╝██║╚██████╗███████╗██████╔╝██████╔╝ ╚═════╝ ╚═╝ ╚═════╝╚══════╝╚═════╝ ╚═════╝
2025-04-17T11:45:32Z INF starting DiceDB version=v1.0.102025-04-17T11:45:32Z INF running with total_commands=402025-04-17T11:45:32Z INF running with engine=ironhawk2025-04-17T11:45:32Z INF running with port=73792025-04-17T11:45:32Z INF running on cores=162025-04-17T11:45:32Z INF running with shards=16
Starting the DiceDB CLI
Section titled “Starting the DiceDB CLI”DiceDB CLI is your portal to all things DiceDB, and once you start you will get a REPL to interact with the database and it looks something like this
localhost:7379>
This indicates that you’re connected to the default DiceDB instance on your local machine on port 7379.
A simple Set-Get Example
Section titled “A simple Set-Get Example”DiceDB is a KV store and one of the most basic operations is to store a key and a value and then retrieve it.
To store <k1, v1>
in DiceDB, we use the SET
command and
then retrieve it using the GET
command.
localhost:7379> SET k1 v1OKlocalhost:7379> GET k1OK "v1"
Here’s a breakdown of what happened,
SET
: This is the DiceDB command to store a valuek1
: This is the key we’re assigning to the valuev1
: This is the actual value we want to store. It’s a simple string in this caseOK
: DiceDB’s response indicating successful storage
Bottom Line
Section titled “Bottom Line”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 reactive applications like chatrooms and leaderboards, handle complex data structures and perform operations efficiently. But all of that after we do our first tutorial for reactivity and query subscriptions.