Implement ZMOVE with WATCH in Redis
The Redis documentation on transactions gives an example of how to implement 开发者_开发百科ZPOP. How do I implement ZMOVE for Redis sorted sets (analagous to SMOVE)?
Is this right? .. to move an element, ele
, from sorted set z1
to z2
and give it SCORE 1, i.e.:
ZMOVE z1 z2 1 ele
WATCH z1 z2
MULTI
ZREM z1 ele
ZADD z2 1 ele
EXEC
I will set the SCORE to be the current time, but I just used 1 here for simplicity.
精彩评论