Home > other >  Reset scores of Redis sorted set after zremrangebyscore
Reset scores of Redis sorted set after zremrangebyscore

Time:12-08

I'm using Redis sorted set to keep some values in order. for example:

score | data
0     |  a
1     |  b
2     |  c
3     |  d

In some situations of my app, I have to remove some of the entries. for example, I delete scores 1 and 2 members:

score | data
0     |  a
3     |  d

I want to change the above to:

score | data
0     |  a
1     |  d

How can I do this?

please help, thanks in advance.

CodePudding user response:

I think it's not possible to use a sorted list in Redis like an indexed array.

If you want to have a sorted list with a sequential score you should take care of it yourself so after every delete, you can overwrite your sorted list with new scores.

  • Related