Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

asaketr64x's avatar

Can I override the value of the score of a member of a redis sorted set?

At present my code is

 Redis::zincrby('users.' . auth()->user()->id . '.chats', time(), $reciever);

But this is misleading . As I don't want to increase the score by an amount of time() rather I want to override the value of score by time() itself . In short how can I change the value of the score ? (I want to override it and not increament it).

0 likes
2 replies
rin4ik's avatar
rin4ik
Best Answer
Level 50

Redis:zrem key data first then Redis:zadd() zadd only counts the number of new elements added. please try this. You'll have to remove the old data and add the new

asaketr64x's avatar

That will work . But seriously a direct command should exist in redis . Anyways thanks

Please or to participate in this conversation.