Example command: ZINCRBY set_name value tie_breaker_weight key
ZINCRBY "myset" 10 1 "one" ZINCRBY "myset" 10 2 "two" ZINCRBY "myset" 10 3 "three"
ZRANK myzset "one" returns 1 ZRANK myzset "two" returns 2 ZRANK myzset "three" returns 3
When you have equal values in a set the tie breaker weight is used to determine the rank.
The use case is as follows. I have 1000 people in a leaderboard. I want the person that arrived at score 10 first to be in first place and the person that arrived at score 10 second to be in second place. Since a leaderboard entry can be updated by more than one client I have to use ZINCRBY. I could use zincrby and do a conditional zadd into another set via zadd but I don't think I can accomplish this without using luna. It would be useful to be able to define a tie breaker so that when I call ZRANK the tie breaker is used if the appropriate options are passed into the command.
Comment From: itamarhaber
@rodriguesd since this appears to be a feature request I suggest that you add more details, especially the context and the use case. I also think it is better to first discuss this at the regular community channels, and only then open an issue if needed.
That said, the suggestion breaks the API so it is unlikely to be accepted as is.
FWIW, an easy way to have this tie breaker is using the score's fractional part, e.g.:
ZADD myset 10.1 "one" 10.2 "two" 10.3 "three"
Comment From: stupidjohn
@rodriguesd since this appears to be a feature request I suggest that you add more details, especially the context and the use case. I also think it is better to first discuss this at the regular community channels, and only then open an issue if needed.
That said, the suggestion breaks the API so it is unlikely to be accepted as is.
FWIW, an easy way to have this tie breaker is using the score's fractional part, e.g.:
ZADD myset 10.1 "one" 10.2 "two" 10.3 "three"
main problem is that the score precision is not enough, add a seconds epoch to score will make real score have only 2^21 size (53 - 32)
Comment From: itamarhaber
This seems to be related to #943, which would be a nicer approach imo. Closing this but feel free to reopen or create a new issue if needed.