Nashpaw
Nashpaw

Reputation: 130

How to have objects in Redis sorted set?

There sorted sets available in Redis, How can I have objects in sorted sets. What I need is sorted object set.

I need to store json structures and edit individual properties inside. What I found is Redis hashes, however I cant do the in-order searches as in the sorted sets there

Upvotes: 3

Views: 2121

Answers (1)

Malinga
Malinga

Reputation: 515

Redis does not support this feature by default. I had the same issue sometime back and We came up with a hybrid, simple data structure that a allows sorted object using Redis Hashes and Redis Sorted-sets.

What we did was, we stored the objects in the redis hashes and we kept a list of all keys in the Redis hashes as a sorted set. This allow us to get all the maps that came after some key. or between two keys. Other than that this allows us to search under topics.

Implementation details: http://www.malinga.me/redis-sorted-object-set-sorted-hashes/

Upvotes: 3

Related Questions