Redis: Redis Command Reference
Redis Command Reference
1. General Commands
▶ Example
Basic connection and operations:
BASH
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SET mykey "Hello"
OK
127.0.0.1:6379> GET mykey
"Hello"
127.0.0.1:6379> DBSIZE
(integer) 1
2. Key Commands
| Command | Description | Syntax |
|---|---|---|
| SET | Set key-value | `SET key value [EX seconds] [PX ms] [NX |
| GET | Get key value | GET key |
| DEL | Delete key | DEL key [key ...] |
| EXISTS | Check key exists | EXISTS key [key ...] |
| EXPIRE | Set expiration | EXPIRE key seconds |
| TTL | View expiration | TTL key |
| KEYS | Find keys | KEYS pattern |
| SCAN | Iterate keys | SCAN cursor [MATCH pattern] [COUNT count] |
❓ FAQ
Q How to view detailed usage of a command?
A Use
HELP command_name in redis-cli, e.g. HELP SET, to display syntax, description, and version info.Q Are Redis commands case-sensitive?
A Redis commands are case-insensitive; SET and set are equivalent. However, key names and values are case-sensitive.
Q How to view all supported Redis commands?
A Use the
COMMAND command to list all commands, or COMMAND INFO command_name for specific command details.📖 Summary
- General: PING, INFO, DBSIZE, FLUSHDB, etc.
- Key operations: SET, GET, DEL, EXISTS, EXPIRE, KEYS, SCAN
- Strings: SET, GET, INCR, DECR, APPEND, STRLEN
- Hashes: HSET, HGET, HGETALL, HDEL, HKEYS, HVALS
- Lists: LPUSH, RPUSH, LPOP, RPOP, LRANGE, LLEN
- Sets: SADD, SREM, SMEMBERS, SISMEMBER, SINTER, SUNION
- Sorted Sets: ZADD, ZRANGE, ZREVRANGE, ZSCORE, ZRANK, ZREM
📝 Exercises
- Command lookup: Use HELP to view detailed descriptions of SET, GET, and HSET commands
- Command classification: Organize Redis commands by type into notes
- Command practice: Execute at least 3 different commands for each data type