Hash Sets are not needed (nor preferred), if you need the complete object or record at retrieval in most of your scenario's. A Hash Set is like a mini-redis database inside Redis. Each key has overhead, and each member of a Hash Set has overhead.
I recommend this approach:
- Serialize your data as messagepack.
- Use a Hash Set, but put a complete record in each member of that Hash Set. Only reason for using a Hash Set: This helps keeping things organized. Simple get/set would work as well.
- If you want an numeric index 'almost' for free, use a Sorted Set instead of a Hash Set. You can use the score as an index. 2.8.9+: Raw alphabetical index also supported: Put everything under score 0 , prefix your msgpack data with an alphabetical identifier/searchstring (plus a delimiter,
\t
is normally a good one) and use the new functionZRANGEBYLEX
. - Pipeline your data
- When doing bulk transfers, wrap the data again in a messagepack container, 1000 records a piece (indication), and let a server-side Lua script do the work for you.
Hope this helps, TW