Rob Stanford
Rob Stanford

Reputation: 35

Best way to retrieve Redis list values in Ruby?

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 need to iterate through all of these values in Ruby, is it more performant to:

  1. Use lrange to get all the values in one trip, then iterate through them in Ruby
  2. Use llen to count the values in the list, then loop through in Ruby using lindex to retrieve each value as an individual trip to Redis

Upvotes: 1

Views: 1190

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230286

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.

Upvotes: 1

Related Questions