redis-packhash npm Package Cuts Redis Memory Use by 87% Using Listpack Hashes
A developer has released redis-packhash, a dependency-free npm package designed to reduce Redis memory consumption by storing small values in compact listpack-encoded hashes instead of individual keys. In a benchmark involving one million keys, memory usage dropped from 53.8 MB to 6.9 MB, an 87% reduction. The package works with popular Redis clients like ioredis and node-redis, requiring users to specify only an expected key count, after which it automatically manages bucket distribution using the FNV-1a hash function. It supports standard operations including get, set, del, has, and batch methods mget and mset, while accepting only string keys and values. Users are cautioned that setting the expectedKeys parameter too low can cause buckets to overflow and revert to a less efficient hashtable encoding, losing all memory savings.
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