Command Palette

Search for a command to run...

Hectal
Phase 4Intermediate5 of 17 in Redis

Specialised Data Structures

Bitmaps, HyperLogLog, geospatial indexes, Bloom and friends, JSON with secondary indexes, and vector search: the structures that turn a hard problem into one command.

These structures trade generality for huge wins on specific problems: counting 100M daily users in 12 MB, estimating unique visitors in 12 KB, finding drivers within 5 km, rejecting non-existent IDs without touching the database, querying JSON by field, and finding semantically similar text for AI features.

Redis 8 ships JSON, the Query Engine, time series and probabilistic structures in the core server. On Valkey or older Redis, the same features come from modules (valkey-json, valkey-bloom, valkey-search, or Redis Stack). Each topic notes where that matters.

0/6 · 0%
6 topics ~59 min 11 code blocks & diagrams
Start with the first topic
1
4.1

Bitmaps: One Bit per User

A bitmap is a string treated as an array of bits, addressed by offset. With dense integer IDs, you can track a yes/no fact for 100M users in 12 MB, count them with BITCOUNT, and combine days with BITOP.

9 min 1 code practice

2
4.2

HyperLogLog: Counting Uniques in 12 KB

HyperLogLog estimates how many distinct items you've seen, with about 0.81% standard error, in at most 12 KB per key, no matter whether you count a thousand or a billion. It can't tell you whether a specific item was seen.

9 min 2 code practice

3
4.3

Geospatial: Nearby Drivers and Stores

Redis GEO stores longitude/latitude points in a sorted set, using a 52-bit geohash as the score, and answers "what's within 5 km of here?" with GEOSEARCH. It's fast and simple, and the hard parts at scale are update volume, hot regions and stale positions.

10 min 1 diagram 1 code practice

4
4.4

Bloom, Cuckoo, Count-Min and Top-K

Probabilistic structures answer "definitely not / maybe yes", "roughly how often", and "roughly the top K" in tiny, fixed memory. Redis 8 includes Bloom and Cuckoo filters, Count-Min Sketch, Top-K and t-digest; on Valkey, valkey-bloom provides Bloom filters.

10 min 1 diagram 1 code practice

5
4.5

JSON and the Query Engine: Documents with Indexes

Redis 8 stores native JSON documents you can read and update by path, and the Query Engine adds secondary indexes over hashes and JSON: full-text, numeric ranges, tags, geo, sorting and aggregations. It turns Redis from key-only lookup into a queryable, in-memory document store.

10 min 1 code practice

6
4.6

Vector Search and Semantic Caching for AI Features

Redis can store embedding vectors and find the nearest ones with HNSW or exact (FLAT) indexes, which powers RAG retrieval, recommendations and semantic caching of LLM responses. Redis 8 also adds vector sets (VADD, VSIM), a native data type for similarity search.

11 min 1 diagram 2 code practice