0
0
Redisquery~5 mins

Redis CLI (redis-cli) basics

Choose your learning style9 modes available
Introduction
Redis CLI lets you talk directly to Redis to store, get, and manage data quickly and simply.
You want to quickly check or change data in Redis without writing a program.
You need to test Redis commands to learn how they work.
You want to debug or monitor Redis data during development.
You want to run simple Redis commands from your computer terminal.
You want to explore Redis features interactively.
Syntax
Redis
redis-cli [options] [command] [arguments]
You type commands after redis-cli prompt to interact with Redis.
Commands are simple words like SET, GET, DEL followed by keys or values.
Examples
Connect to Redis, store the word Hello under mykey, then get it back.
Redis
redis-cli
SET mykey "Hello"
GET mykey
Delete the key named mykey from Redis.
Redis
redis-cli DEL mykey
Increase the number stored in counter by 1.
Redis
redis-cli INCR counter
Sample Program
This stores a greeting message and then retrieves it.
Redis
redis-cli
SET greeting "Hi there!"
GET greeting
OutputSuccess
Important Notes
Commands are case-insensitive but usually written in uppercase for clarity.
If Redis is on another computer or port, use -h and -p options to connect.
Use CTRL+C to exit redis-cli interactive mode.
Summary
redis-cli is a simple tool to send commands to Redis.
You can set, get, delete, and modify data easily.
It helps you learn and test Redis commands quickly.