Back to Cheat Sheets
Redis Commands
Basic Redis commands for data structure operations and server management.
| Action | Command | Details |
|---|---|---|
| Connect to server | redis-cli |
Open Redis command-line interface. |
| Set key | SET key value |
Set a key to hold a string value. |
| Get key | GET key |
Get the value of a key. |
| Delete key | DEL key |
Remove a key. |
| Check existence | EXISTS key |
Check if a key exists. |
| Expire key | EXPIRE key seconds |
Set a timeout on a key. |
| List keys | KEYS pattern |
Find keys matching pattern. |
| Flush all | FLUSHALL |
Delete all keys in all databases. |
| List all databases | INFO keyspace |
Show database info. |
| Increment | INCR key |
Increment integer value by 1. |
| Push to list | LPUSH list value |
Add value to start of list. |
| Pop from list | RPOP list |
Remove and return last element. |
| Add to set | SADD set member |
Add member to set. |
| Remove from set | SREM set member |
Remove member from set. |
| Publish message | PUBLISH channel message |
Send message to channel. |
| Subscribe | SUBSCRIBE channel |
Listen for messages on a channel. |