REDIS CHEAT SHEET

In-Memory Data Store
v1.0
String Commands
  • SET key valueSet value
  • GET keyGet value
  • INCR keyIncrement by 1
  • INCRBY key nIncrement by n
  • DECR keyDecrement by 1
  • APPEND key valAppend to value
  • STRLEN keyValue length
List Commands
  • LPUSH key valPush to left
  • RPUSH key valPush to right
  • LPOP keyPop from left
  • RPOP keyPop from right
  • LRANGE key 0 -1Get all items
  • LLEN keyList length
  • LINDEX key nGet by index
Set Commands
  • SADD key valAdd member
  • SREM key valRemove member
  • SMEMBERS keyGet all members
  • SISMEMBER key valCheck member
  • SCARD keySet size
  • SUNION k1 k2Union sets
  • SINTER k1 k2Intersect sets
Hash Commands
  • HSET key field valSet field
  • HGET key fieldGet field
  • HMSET key f1 v1...Set multiple
  • HGETALL keyGet all fields
  • HDEL key fieldDelete field
  • HEXISTS key fieldField exists
  • HKEYS keyAll field names
Sorted Set Commands
# Add member with score ZADD leaderboard 100 "player1" ZADD leaderboard 200 "player2" # Get range by rank (0 = highest score with REV) ZRANGE leaderboard 0 9 REV WITHSCORES # Get score ZSCORE leaderboard "player1" # Increment score ZINCRBY leaderboard 50 "player1" # Get rank (0-indexed) ZRANK leaderboard "player1"
Key Commands
# Key management KEYS * # List all keys (use SCAN in prod) EXISTS key # Check if key exists DEL key # Delete key TYPE key # Get key type RENAME old new # Rename key # Expiration EXPIRE key 60 # Set TTL (seconds) TTL key # Get remaining TTL PERSIST key # Remove expiration SETEX key 60 val # Set with expiration
Pub/Sub Commands
  • SUBSCRIBE channelSubscribe
  • UNSUBSCRIBE channelUnsubscribe
  • PUBLISH channel msgPublish message
  • PSUBSCRIBE patternPattern subscribe
Connection & Server
  • PINGTest connection
  • SELECT nSwitch database
  • FLUSHDBClear current DB
  • FLUSHALLClear all DBs
  • INFOServer info
  • DBSIZEKey count
Common Patterns
# Session storage SETEX session:abc123 3600 '{"user_id": 1, "name": "John"}' # Rate limiting INCR ratelimit:user:1 EXPIRE ratelimit:user:1 60 # Cache pattern GET cache:user:1 # Try cache first SETEX cache:user:1 300 'data' # Cache miss: store with TTL # Counter INCR page:views:home GET page:views:home
Data Types Summary
  • StringText, numbers, JSON
  • ListOrdered collection
  • SetUnique unordered
  • HashField-value pairs
  • Sorted SetScored members
CLI Connection
  • redis-cliConnect locally
  • redis-cli -h hostRemote host
  • redis-cli -p 6379Specify port
  • redis-cli -a passWith password

DummyDataGenPro

Realistic synthetic test data with foreign keys that actually join.

All 51 cheat sheets

Free to read and free to print — no signup. Want them as A4 PDFs you can print? Get all 51 as a PDF bundle for £14.99.
A Martkos IT reference sheet · Blog · Free tools