Redis data structures: Hash, Sorted Set and what they cost
A hash goes from 136 to 336 bytes and 100,000 uniques fit in 14,392 bytes: Hash, Sorted Set and HyperLogLog measured, and why MEMORY USAGE is an estimate.
Ten articles on Redis tested on real instances: data structures, Pub/Sub and Streams, Lua, persistence, maxmemory, cache, locks, outages and HNSW search.
This series collects 10 articles (approximately 190 minutes of total reading time), designed for a level Intermediate. The main topics covered are Redis, Redis Sorted Set, Redis Pub/Sub, Redis persistenza.
A hash goes from 136 to 336 bytes and 100,000 uniques fit in 14,392 bytes: Hash, Sorted Set and HyperLogLog measured, and why MEMORY USAGE is an estimate.
With Pub/Sub a message with no reader vanishes, with Streams it waits: both strategies tried on Redis 8.0.5 and 7.4.7, with real output.
GET then DEL deletes someone else's lock; a Lua script doesn't. EVAL, EVALSHA, WATCH and the cost of BUSY, measured on Redis 8.0.5 and 7.4.7.
Same configuration, two ways to stop Redis: with kill -9 zero of a thousand keys survive, with an orderly shutdown all of them. Measured on 8.0.5 and 7.4.7.
A full instance rejects writes or throws keys away. Which policy deletes the data you can't rebuild, measured on Redis 8.0.5 and 7.4.7.
After a release the cache serves old-code data. A version prefix avoids it without FLUSHALL: what it costs in memory, measured on Redis 8.0.5.
An unconditional DEL deletes the lock of whoever took over after the expiry. The flaw reproduced with redis-cli, the fix with a token and Lua, and its limit.
JWT revocation, idempotency, locks, tokens and cache each answer differently when Redis is silent. The table from the code and the 2-second timeout measured.
The client measured 238 ms per command, the server 1.28 microseconds: how to measure latency, slow commands and bytes per key on Redis 8.0.5 and 7.4.7.
With the defaults Redis's HNSW misses true neighbours: recall 0.94 on 300 real searches. How to measure it with a FLAT and what EF_RUNTIME changes.