Redis Cheat Codes
Redis Cheat Codes for string caching, hashes, lists, pub/sub, Lua scripts, and memory management. 20 essential cheat codes ready to copy and execute.
Store and retrieve key-value string pairs.
SET key "value" / GET key SET user:42 "Alex" / GET user:42 Set key-value pair with TTL expiration seconds.
SET key "value" EX seconds SET cache:session "token_123" EX 3600 Store and fetch structured hash fields.
HSET key field "val" / HGETALL key HSET user:101 name "Alex" email "a@b.com" / HGETALL user:101 Push element to list head and pop from tail (queue).
LPUSH key "val" / RPOP key LPUSH jobs "job_99" / RPOP jobs Add unique members to set and fetch all members.
SADD key "member" / SMEMBERS key SADD tags:post:10 "sql" "nosql" / SMEMBERS tags:post:10 Add member with score and fetch top leaderboard ranks.
ZADD key score "member" / ZREVRANGE key 0 -1 WITHSCORES ZADD leaderboard 2500 "PlayerA" 1800 "PlayerB" / ZREVRANGE leaderboard 0 2 WITHSCORES Publish message to channel and subscribe.
PUBLISH channel "msg" / SUBSCRIBE channel PUBLISH news:updates "New release live!" Atomically increment or decrement integer key.
INCR key / DECR key INCR page:views:42 Set TTL expiration seconds on key and check remaining TTL.
EXPIRE key seconds / TTL key EXPIRE rate:limit:ip 60 / TTL rate:limit:ip Delete specified key from Redis memory.
DEL key1 key2 DEL cache:user:42 Check if key exists in memory.
EXISTS key EXISTS session:active:10 Iterate over database keys safely without blocking.
SCAN cursor MATCH pattern COUNT n SCAN 0 MATCH user:* COUNT 100 Execute atomic block of commands sequentially.
MULTI ... commands ... EXEC MULTI; INCR visits; EXPIRE visits 60; EXEC; Set and get multiple key-value pairs simultaneously.
MSET k1 "v1" k2 "v2" / MGET k1 k2 MSET user:1 "A" user:2 "B" / MGET user:1 user:2 Track unique cardinality with 12KB memory footprint.
PFADD key "val" / PFCOUNT key PFADD uv:2026-01-01 "ip_1" "ip_2" / PFCOUNT uv:2026-01-01 Store spatial coordinates and measure distance.
GEOADD key long lat "member" / GEODIST key m1 m2 km GEOADD cities -73.98 40.74 "NYC" -118.24 34.05 "LA" / GEODIST cities NYC LA km Execute atomic server-side Lua script.
EVAL "script" numkeys key1 arg1 EVAL "return redis.call('get', KEYS[1])" 1 mykey Wipe all keys from all Redis databases.
FLUSHALL [ASYNC] FLUSHALL ASYNC Inspect memory consumption and fragmentation.
INFO memory INFO memory Read or alter Redis runtime settings.
CONFIG GET param / CONFIG SET param val CONFIG GET maxmemory / CONFIG SET maxmemory 2gb No cheat codes found matching your search term.