What is the most common way is to retrieve all values in a list when those values are relatively large serialised Ruby objects?
For example:
- I have 5000 values in a Redis list
- Each value in the list contains a 50K Ruby object serialised as a string
I need to iterate through all of these values in Ruby, is it more performant to:
- Use
lrangeto get all the values in one trip, then iterate through them in Ruby - Use
llento count the values in the list, then loop through in Ruby usinglindexto retrieve each value as an individual trip to Redis
I’d say, it makes no difference. Choose one that is easier to code for you. Any speed gains from using LRANGE will be dominated by time needed to transfer your large objects. I would probably process them one by one, this way it uses less memory.