Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add incrementScore to RedisZSet #3256

Open
@vinsguru

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

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /