I'm trying to create a space-efficient histogram in Redis. To do so, instead of storing 1000 measurements, I'm creating an array of 25 range interval buckets and storing the number of times the measurement falls in that range so I only have to store 25 integers instead of 1000 integers.
I want to store the array as a list in Redis but in order to concurrently update all of the buckets from many different processes, I really need to use something like HINCRBY. I'd like to see a command like LINCRBY key index amount so I can pipeline update each bucket quickly and safely.
Comment From: itamarhaber
Heya @mperham - cool to have you drop by with this idea. However.
Have you considered the BITFIELD command/DT? You can use multiple INCRBY clauses to atomically update any number of offsets. Makes sense?
P.S. using a list for this doesn't sound like a good idea because of access complexity. Static arrays can be implemented with a Hash or a String (and Bitfields are a specialized built-in variant for counters on the latter).
Comment From: mperham
Thank you so much! I didn’t know about this command but it looks exactly like what I need and it’s been around since 3.2 so I can start using it immediately.
Comment From: itamarhaber
I'm happy to return at least one favor - your work has been for me one hell of an src of inspiration :)