Core Java

Introduction to DiceDB

DiceDB is an open-source, easy-to-use in-memory database designed for modern applications. It supports fast data access and real-time updates, making it ideal for learning how reactive systems and caching work in practice.

Note: DiceDB development has currently been paused, but the available tools and SDKs still function well for experimentation and lightweight use cases.

This article provides a guide to getting started with DiceDB—from installing the server using Docker, setting up the CLI, to executing your first commands.

1. Installation Options for DiceDB

DiceDB supports multiple installation methods depending on your development environment and preferences:

  • Using Docker (the quickest and easiest way)
  • Building from source (for advanced users)

This guide focuses on using Docker to start the DiceDB server and then interact with it via the official CLI tool.

2. Setting Up DiceDB with Docker

The most straightforward way to run DiceDB locally is by using Docker. With a single command, you can have the server running and ready to accept commands.

docker run -p 7379:7379 dicedb/dicedb:latest

This command pulls the latest DiceDB image from Docker Hub and starts the server on your local machine. The service will be accessible at localhost:7379, which is DiceDB’s default port.

When the DiceDB server starts successfully, you should see output resembling the following:

Screenshot showing the DiceDB server startup output for the DiceDB intro

2.1 Installing DiceDB CLI

To interact with DiceDB through a command-line interface, you will need the DiceDB CLI. It allows you to send commands to the running server directly from your terminal.

curl -sL https://raw.githubusercontent.com/dicedb/dicedb-cli/refs/heads/master/install.sh | sh

This script installs the DiceDB CLI globally on your system. After installation, you can use the dicedb command to interact with the server. You must have a running DiceDB instance (e.g., via Docker) before issuing commands.

Note: If your operating system is not supported by the above script, you can follow the manual instructions from the official DiceDB CLI GitHub repository.

Once installed, you can launch the interactive DiceDB prompt by running:

dicedb-cli

This will start the CLI and display a prompt like:

localhost:7379>

Verifying the Setup

After installing the CLI and running the Docker container, verify that everything is working as expected:

localhost:7379> PING

The PING command tests the connection between the CLI and the DiceDB server. If successful, the server responds with PONG.

Output

PONG

3. Using DiceDB: Basic Commands

Once the server and CLI are set up, you can begin interacting with DiceDB using simple commands. Here are a few examples:

Set a Key-Value Pair

Stores a key with the associated value.

localhost:7379> SET greeting "Hello, DiceDB"

Retrieve the Value

Retrieves the value of the given key.

localhost:7379> GET greeting
OK "Hello, DiceDB"

Check if a Key Exists

Returns 1 if the key exists, otherwise 0.

localhost:7379> EXISTS key
OK 0
localhost:7379> EXISTS greeting
OK 1

Delete a Key

Deletes the specified key.

localhost:7379> DEL name
OK 1

List All Keys

Returns all keys matching the pattern (use * to list all).

localhost:7379> KEYS *
OK 
0) friend
1) greeting

4. Conclusion

In this article, we explored how to get started with DiceDB by running it with Docker, installing the DiceDB CLI, verifying the server setup, and executing basic key-value commands. Despite its minimal footprint, DiceDB offers a practical solution for learning, rapid prototyping, and building lightweight storage layers in modern applications.

This article provided an intro to DiceDB.

Omozegie Aziegbe

Omos Aziegbe is a technical writer and web/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button