MULTIRedis Transactions, Pub/Sub, and Streams Cheat Sheet
Atomic transactions, optimistic locking, pub/sub messaging, streams, consumer groups, geo commands, bitmaps, and HyperLogLog.
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
Transactions and optimistic locking
Atomic batches and CAS-style updates.
bashANYredistransactionmulti
bash
bashANYredistransactionexec
bash
EXECbashANYredistransactiondiscard
bash
DISCARDbashANYredistransactionwatch
bash
WATCH account:1 account:2bashANYredistransactionwatch
bash
UNWATCHbashANYredistransactionworkflow
bash
WATCH account:1
GET account:1
MULTI
DECRBY account:1 50
INCRBY account:2 50
EXECIn practice, the client should validate account state after GET and before MULTI/EXEC.
Pub/Sub
Publish messages and subscribe to channels or patterns.
bashANYredispubsubpublish
bash
PUBLISH events:user '{"userId":1,"action":"login"}'bashANYredispubsubsubscribe
bash
SUBSCRIBE events:user events:systembashANYredispubsubpattern
bash
PSUBSCRIBE events:*bashANYredispubsubunsubscribe
bash
UNSUBSCRIBE events:userbashANYredispubsubunsubscribe
bash
PUNSUBSCRIBE events:*bashANYredispubsubinspect
bash
PUBSUB CHANNELSbashANYredispubsubinspect
bash
PUBSUB NUMSUB events:user events:systembashANYredispubsubinspect
bash
PUBSUB NUMPATStreams
Append-only logs, consumer groups, and event processing.
bashANYredisstreamxadd
bash
XADD orders * user_id 1 total 19.99 status paidbashANYredisstreamlength
bash
XLEN ordersbashANYredisstreamread
bash
XRANGE orders - + COUNT 10bashANYredisstreamread
bash
XREVRANGE orders + - COUNT 10bashANYredisstreamread
bash
XREAD COUNT 10 BLOCK 5000 STREAMS orders payments $ $bashANYredisstreamtrim
bash
XTRIM orders MAXLEN ~ 10000bashANYredisstreamconsumer-group
bash
XGROUP CREATE orders order-workers $ MKSTREAMbashANYredisstreamconsumer-group
bash
XREADGROUP GROUP order-workers worker-1 COUNT 10 BLOCK 5000 STREAMS orders >bashANYredisstreamconsumer-group
bash
XACK orders order-workers 1710000000000-0bashANYredisstreamconsumer-group
bash
XPENDING orders order-workersbashANYredisstreamconsumer-group
bash
XCLAIM orders order-workers worker-2 60000 1710000000000-0bashANYredisstreamconsumer-group
bash
XAUTOCLAIM orders order-workers worker-2 60000 0-0 COUNT 100bashANYredisstreaminspect
bash
XINFO STREAM ordersbashANYredisstreaminspect
bash
XINFO GROUPS ordersbashANYredisstreamdelete
bash
XDEL orders 1710000000000-0Geo, bitmaps, and HyperLogLog
Approximate counts, geospatial indexing, and bit operations.
bashANYredisgeolocation
bash
GEOADD cities -122.4194 37.7749 sf -74.0060 40.7128 nycbashANYredisgeolocation
bash
GEOPOS cities sf nycbashANYredisgeodistance
bash
GEODIST cities sf nyc kmbashANYredisgeosearch
bash
GEORADIUS cities -122.4194 37.7749 500 km WITHDISTbashANYredisgeosearch
bash
GEOSEARCH cities FROMLONLAT -122.4194 37.7749 BYRADIUS 500 km WITHDISTbashANYredishyperloglogcount
bash
PFADD unique:visitors user:1 user:2 user:3bashANYredishyperloglogcount
bash
PFCOUNT unique:visitorsbashANYredishyperloglogmerge
bash
PFMERGE unique:all unique:web unique:mobilebashANYredisbitopbitmap
bash
BITOP AND flags:all flags:a flags:bbashANYredisbitmapbitpos
bash
BITPOS feature:flags 1More in Redis
Redis Persistence, Replication, and Cluster Cheat Sheet
RDB, AOF, replication, failover, Lua scripts, functions, and cluster command references for operational Redis use.
Redis Admin and redis-cli Cheat Sheet
redis-cli operational workflows, latency inspection, slowlog, config, ACL, clients, and safe administrative controls.
Redis Data Types Cheat Sheet
High-value Redis commands for lists, sets, hashes, and sorted sets used in queues, objects, tags, and leaderboards.
Redis Cheat Sheet
Comprehensive Redis commands for redis-cli, key lifecycle, strings, expiration, and core operational workflows.