HomeCheat SheetsRedis CLI Commands & In-Memory Data Structures Cheat Sheet
100% Client-Side β€’ 0 B Data Leaves Browser
database

Redis CLI Commands & In-Memory Data Structures Cheat Sheet

Comprehensive Redis command reference for developers. Keys, Strings, Hashes, Lists, Sets, Sorted Sets, Pub/Sub, and Server Monitoring.

Key Expiration & Strings

Set string key with automatic 1-hour expiration (TTL)SET key "value" EX 3600
Retrieve value stored at keyGET key
Atomically increment numerical value by 1 or specified amountINCR key / INCRBY key 5
Check remaining time-to-live in seconds (-1 = infinite, -2 = expired)TTL key
Set key timeout to 60 secondsEXPIRE key 60
Delete one or more keysDEL key1 key2
Check if key exists (returns 1 or 0)EXISTS key

Hashes & Lists

Store multiple field-value pairs inside a Redis hashHSET user:1 name "Ada" role "Lead"
Retrieve specific field from hashHGET user:1 name
Retrieve all fields and values from hashHGETALL user:1
Prepend item to head of list (queue producer)LPUSH queue "job_1"
Remove and return item from tail of list (FIFO worker)RPOP queue
Blocking pop: waits up to 30 seconds for an item to arriveBRPOP queue 30

Sorted Sets (ZSET) & Realtime Ranking

Add member with floating-point numerical scoreZADD leaderboard 1500 "user_a"
Get Top 10 highest-scoring leaderboard entriesZREVRANGE leaderboard 0 9 WITHSCORES
Increment player score by 50 pointsZINCRBY leaderboard 50 "user_a"
Get 0-indexed ranking of player based on highest scoreZREVRANK leaderboard "user_a"

Monitoring & Administration

Display memory usage, fragmentation ratio, and peak RAMINFO memory
Stream all incoming Redis commands processed by server in real timeMONITOR
Inspect the 10 most recent queries that exceeded slow thresholdSLOWLOG GET 10
Delete all keys in current database / all databases (caution)FLUSHDB / FLUSHALL

Frequently Asked Questions

β€’ Why should KEYS * never be run in production Redis?

Redis is single-threaded. `KEYS *` scans the entire keyspace synchronously, blocking all other application requests and queries until it finishes. Use `SCAN` instead for non-blocking iteration.