-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
status: ideal-for-contributionAn issue that a contributor can help us withAn issue that a contributor can help us withtype: enhancementA general enhancementA general enhancement
Description
RedisZSet provides a convenient collection-like abstraction around Redis sorted sets (ZSET).
However, it currently lacks a method for the most common operation on sorted sets like incrementing a member’s score (ZINCRBY).
Developers have to use ZSetOperations manually:
redisTemplate.opsForZSet().incrementScore(key, member, delta);
This defeats the purpose of using RedisZSet, which is intended to offer a unified, object-oriented API over ZSET operations.
Proposed Solution
Add a new default method to RedisZSet:
default Double incrementScore(V value, double delta) {
return getOperations().opsForZSet().incrementScore(getKey(), value, delta);
}
This aligns with the existing ZSetOperations.incrementScore() method and allows idiomatic usage:
var leaderboard = RedisZSet.create("leaderboard", ops, 0.0);
leaderboard.incrementScore("player:7", 5.0);
Metadata
Metadata
Assignees
Labels
status: ideal-for-contributionAn issue that a contributor can help us withAn issue that a contributor can help us withtype: enhancementA general enhancementA general enhancement