Connect with redis-cli
This example demonstrates how to connect to Dragonfly® using
redis-cli
, which supports nearly all the same commands as it does for
Redis®. For more information, see Dragonfly
CLI.
Variables
Replace the following placeholders in the code sample with the appropriate values:
Variable | Description |
---|---|
DRAGONFLY_URI | URL for the Dragonfly connection |
Prerequisites
Ensure the following before proceeding:
- The
redis-cli
client installed. This can be installed as part of the Redis®* server installation or as a standalone client. Refer to the Redis Installation Guide for more information.
Code
To connect to Dragonfly, execute the following command in a terminal window:
redis-cli -u DRAGONFLY_URI
This command connects you to your Dragonfly instance.
To verify the connection is successful, use the INFO
command:
INFO
This command should return various Dragonfly parameters similar to Redis:
# Server
dragonfly_version:1.0.0
dragonfly_git_sha1:0a1b2c3d
dragonfly_mode:standalone
...
To set a key, use the following command:
SET mykey mykeyvalue123
This should return a confirmation OK
.
To retrieve the set key value, use:
GET mykey
The output will be the value of the key, in this case,
"mykeyvalue123"
.