Quick Reference · in-memory data structure store

redis cheat sheet 7.x / 8.x

Redis keeps keys in RAM, each holding one data structure. Commands either inspect keys, mutate a structure, read from it, or operate the server. Redis 7 added Functions, ACL selectors, and sharded pub/sub; 7.4 added hash-field TTL; and Redis 8 folded JSON, Search/Query, Time Series, probabilistic types & Vector Sets into the core. Cards tagged 7.x/8.0 mark version-gated features; module marks types that were separate before Redis 8.

connect / keys strings / scalars collections read / query admin / ops 7.x / 8.x new destructive most common

Distilled & cross-checked against: redis.io/docs · Redis 7.0 / 7.2 / 7.4 release notes · Redis 8.0 (Open Source) GA notes · commands reference · Functions & ACL intros · quickref.me

One key, one structure — pick the shape that fits the access pattern
key"user:42" String List Hash Set Sorted Set Stream Bitmap / HLL REDIS 8 — NOW BUILT-IN (was Redis Stack) JSON Time Series Bloom / Cuckoo CMS / Top-K / t-digest Vector Set (beta) Choosing a structure • String — counters, cached blobs, bitmaps. GET/SET, INCR. • List — queues, stacks, timelines. LPUSH/BRPOP. • Hash — objects with fields; 7.4 adds per-field TTL. • Set — membership, tags, unique visitors. SADD/SISMEMBER. • Sorted Set — leaderboards, priority, rate limits. ZADD. • Stream — event log with consumer groups. XADD/XREADGROUP. • JSON — nested documents, indexed by the Query Engine. • Vector Set / Search — semantic similarity for AI / RAG. • Probabilistic — huge-scale approximate counting/membership.
01Connect & CLIredis-cli
02Keys — Genericmeta · any type
03Expiry & TTLmeta
04Stringsscalars · counters · blobs
05Listscollections · queues & stacks
06Hashescollections · objects
07Hash Field TTL 7.4+expire individual fields
08Setscollections · unique members
09Sorted Setscollections · leaderboards
10Multi-Key Pop 7.0+collections · fan-in
11Bitmaps & HyperLogLogstrings · compact analytics
12Streamscollections · event log
13Geospatialsorted-set backed
14Transactionsadmin · MULTI/EXEC
15Pub/Submessaging
16Scriptingadmin · Lua EVAL
17Functions 7.0+admin · persistent server-side
18JSON 8.0 modulenested documents
19Query Engine 8.0 moduleread · secondary index & search
20Vector Sets 8.0 betaread · AI similarity
21Time Series 8.0 modulemetrics & IoT
22Probabilistic 8.0 moduleapproximate at scale
23Persistenceadmin · durability
24Replicationadmin · HA
25Clusteradmin · horizontal scale
26ACL & Security 7.0+ selectorsadmin · access control
27Client & Caching 7.xadmin · connections
28Server & Configadmin
29Data Types at a Glancevalue → use case

Core

Stringcache, counter, blob, bitmap base
Listqueue, stack, timeline
Hashobject; per-field TTL (7.4)
Set / Sorted Settags, uniqueness / leaderboards

Streaming & probabilistic

Streamevent log + consumer groups
Bitmap / HLLflags / approx-unique count
Bloom/Cuckoo/CMSmembership / frequency (8.0)

Document & geo

JSONnested docs, indexable (8.0)
Geoproximity on a sorted set
Time Seriesmetrics, IoT, downsampling (8.0)

AI

Vector Setembeddings, semantic search (8.0 beta)
Query Enginesecondary index, KNN, full-text (8.0)
30Time Complexityknow before you scale
GET/SET/HGETO(1) — constant
LPUSH/RPUSH/LPOPO(1) at the ends
LINDEX / LINSERTO(n) — walks the list
SADD/SISMEMBERO(1)
ZADD / ZRANKO(log n)
ZRANGE k 0 mO(log n + m)
HGETALL / SMEMBERSO(n) — whole collection
KEYS *O(n) — blocks; use SCAN
SCAN / HSCANO(1) per call, cursored
PFCOUNTO(1), ~12KB per HLL
31Keyspace Notificationsadmin · react to changes
32Danger Zonedestructive · think twice

Three things worth picturing

The mental models that most change how you use Redis 7.x / 8.x — drawn from the Functions, hash-TTL, and Redis 8 release notes.

EVAL script vs. Function

EVAL ships the whole script every call and vanishes on restart; a Function is loaded once, named, persisted, and replicated.

EVAL (ephemeral) client Lua VMlost on restart full body every call FUNCTION (persistent) client library "mylib"AOF + replicated LOAD once FCALL name

Hash field TTL 7.4

Before 7.4 a TTL applied to the whole key; now each field can expire on its own clock — ideal for session bundles.

HEXPIRE per field session:42 tokenTTL 900s csrfTTL 60s ⌛ themeno TTL csrf expires; token & theme stay

Redis 8: one binary 8.0

Search, JSON, Time Series, probabilistic types & Vector Sets were separate modules; Redis 8 folds them into Redis Open Source.

before: modules Search JSON TS Bloom Cuckoo… Redis 8 Redis OSS 8 + Search / Query + JSON + Time Series + Bloom/Cuckoo/CMS + Top-K / t-digest + Vector Set (beta) one binary, no modules

Worth memorizing

SCAN not KEYSKEYS * blocks the single thread; SCAN iterates with a cursor
DEL vs UNLINKUNLINK frees memory in a background thread — non-blocking
EVAL vs FUNCTIONscripts are ephemeral; Functions persist, replicate & are called by name
key TTL vs field TTL7.4 HEXPIRE expires one hash field, not the whole key
SUBSCRIBE vs SSUBSCRIBEsharded pub/sub (7.0) scales across a cluster; emits smessage
txns don't roll backMULTI/EXEC is atomic; a queued command error doesn't undo the rest
ACL selectors7.0 lets one user carry multiple key-pattern + command rule sets
RESP3HELLO 3 unlocks maps, push messages & client-side caching
Redis 8 = one binaryJSON, Search, Time Series, probabilistic, Vector Sets built in
listpack7.0 encoding replacing ziplist; check with OBJECT ENCODING
multi-part AOF7.0 base + incremental files + manifest — cheaper rewrites
probabilistic = tinyBloom/CMS/HLL trade exactness for huge memory savings at scale