What is the usual way to store objects in a sorted set in redis?

What is the most convenient / fast way to implement a sorted set in redis, where the values ​​are objects, not just strings.

Should I just store the object identifier in a sorted set and then request each of them individually by its key or is there a way I can store them directly in the sorted set, i.e. should the value be a string?

+4
source share
2 answers

It depends on your needs, if you need to share this data with other zsets / structure and want to write the value only once for each change, you can put id as the zset value and add a hash to store the object. However, this involves creating additional requests when reading data from zset (one zrange + n hgetall for n values ​​in zset), but writing and synchronizing values ​​between many structures is cheap (only updating the hash corresponding to the value).

"", - zset, (JSON, MESSAGEPACK, KRYO...) , zset. , zset ( 1 O (log (N) + M), , , , ), , , zsets/, / , .

Redis , , , , .

, , redis , , (- , ), / lua. , ( , , ), , , , ( redis, ).

+5

: ,

: . MsgPack JSON, .

+1

All Articles