Redis CLI Commands Quick Reference
Frequently used Redis commands for managing data structures, persistence, and server administration.
Key Operations
SET key value # Set a key
GET key # Get a value
DEL key [key ...] # Delete one or more keys
EXISTS key # Check if key exists (1=yes, 0=no)
EXPIRE key seconds # Set TTL on a key
TTL key # Get remaining TTL
KEYS pattern # Find keys matching pattern (use SCAN in production)
SCAN 0 MATCH prefix:* # Iterate keys safelyStrings
SET counter 0
INCR counter
INCRBY counter 5
APPEND key valueLists
LPUSH mylist value # Push to head
RPUSH mylist value # Push to tail
LPOP mylist # Pop from head
LRANGE mylist 0 -1 # Get all elements
BLPOP mylist timeout # Blocking popHashes
HSET user:1 name "Ravi" email "r@example.com"
HGET user:1 name
HGETALL user:1
HDEL user:1 emailSets
SADD myset member1 member2
SMEMBERS myset
SISMEMBER myset member1
SREM myset member1Server
INFO # Server statistics
DBSIZE # Number of keys in current DB
SELECT 1 # Switch to database 1
BGSAVE # Trigger background save
SHUTDOWN SAVE # Save and shut down
FLUSHDB # Delete all keys in current DB
FLUSHALL # Delete all keys in all DBs