Valkey 9.1 hash field TTL triples memory use in its own documented pattern
Valkey 9.1 introduced HSETEX, allowing developers to set a hash field and its expiry in a single command, mirroring the per-user auth token example shown in Valkey's official blog. A developer benchmarked this pattern against 20,000 keys and found the hash-per-item approach with a field TTL consumed roughly three times more RAM than a plain string key with EXPIRE. The culprit is an encoding switch: setting any field TTL on a hash immediately forces it from the compact listpack format to the heavier hashtable format, regardless of hash size. This behavior is a known issue tracked in Valkey GitHub issue #2618, but a fix had not landed as of version 9.1.2. The feature performs efficiently when applied to large hashes already using hashtable encoding, adding around 23 bytes per field — the pattern it was actually designed for, not the single-field-per-hash example in the docs.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in