Specialized Types
HyperLogLog, geo, JSON, search, time series, Bloom filters, and vector sets
Beyond the five core types, Redis has types that trade exactness for tiny memory (HyperLogLog, Bloom filters), and, since Redis 8, the formerly separate modules built in: JSON, a query engine, time series, and vector similarity. Confirm they're loaded:
MODULE LIST
# timeseries, search, bf (Bloom), ReJSON, vectorsetHyperLogLog: count unique things in 12 KB
A HyperLogLog estimates the number of distinct elements with a standard error of 0.81%, using at most 12 KB, whether you add a thousand items or a billion.
Storing every visitor ID in a set would cost tens of MB per day at scale; the HyperLogLog is 12 KB per day, forever. The catch: you can count but never list members, and you can't remove one.
The idea: hash each element and look at the number of leading zeros. Seeing a hash with 20 leading zeros suggests you've seen around 2^20 distinct elements. Averaging this over 16,384 buckets (registers) makes the estimate stable. Small HLLs use a sparse encoding and grow to the 12 KB dense form as they fill up.
Geospatial
Geo commands store longitude/latitude in a sorted set (the score is a 52-bit geohash), so they get range queries for free:
Typical uses: nearest stores, drivers within 2 km, delivery zones.
JSON
Native JSON documents with path-based reads and atomic updates of nested fields:
Use JSON when objects are nested and you update parts of them. A flat object is still cheaper as a hash.
Search and query
The Redis Query Engine builds secondary indexes over hashes or JSON documents, kept up to date automatically on every write:
FT.CREATE idx:product ON HASH PREFIX 1 app:product: SCHEMA
name TEXT
category TAG
price NUMERIC SORTABLE
FT.SEARCH idx:product "@category:{peripherals} @price:[0 60]" RETURN 2 name price
# 2 results: Webcam (59), USB-C hub (39)
FT.SEARCH idx:product "keyboard" # full-text
FT.AGGREGATE idx:product "*" GROUPBY 1 @category REDUCE AVG 1 @price AS avg_priceThis answers "find products in a category under $60" without maintaining your own sets of IDs per category and price band. It's useful, but it doesn't make Redis a relational database: indexes cost memory, and there are no joins.
Time series
Good for application-level metrics or IoT readings that need sub-millisecond writes. For infrastructure metrics, Prometheus is the right tool.
Bloom and Cuckoo filters
A Bloom filter answers "have I seen this?" with no false negatives and a tunable false-positive rate, in a fraction of the memory a set would take:
Classic uses: "has this user already seen this article?", "is this
username taken?" before hitting the database, skipping cache lookups for
keys that can't exist. Cuckoo filters (CF.*) also support deletion.
There are also Count-Min Sketch (CMS.*, approximate frequencies) and
Top-K (TOPK.*, heavy hitters).
Vector sets
Redis 8 adds vector sets for similarity search over embeddings:
VADD app:vec VALUES 3 0.1 0.2 0.3 item:1
VADD app:vec VALUES 3 0.9 0.1 0.0 item:2
VSIM app:vec VALUES 3 0.1 0.2 0.25 COUNT 1 # nearest neighbour: item:1Real embeddings have hundreds of dimensions. The query engine's
VECTOR fields offer the same capability inside a search index, combined
with filters.
Probabilistic structures are approximate by design. A HyperLogLog count is ±0.81%; a Bloom filter at 1% will say "seen" for about 1 in 100 new items. That's fine for analytics and pre-filtering. It's wrong for anything where a false answer has a cost, like "has this payment been processed?"
Lab
PFCOUNT app:visitors:todayandMEMORY USAGE app:visitors:today. Compare with what a set of the same IDs would cost.- Build the
idx:productindex and search for@category:{audio}. ThenHSET app:product:1007 name Speaker category audio price 49and search again. The new product is indexed immediately. - Create a Bloom filter for 1,000 items at 1%, add 1,000 items, then test 1,000 different items and count the false positives.