Spring data redis zadd command missed nx|xx|incr options

Viewed 277

Lettuce supported zadd's NX|XX|CH|INCR options on 2015 link.

But I can't find any thing support this in Lettuce's wrapper Spring data Redis (version:2.1.5).

It seem that the only two zadd methods that DefaultZSetOperations provide can't let me use NX|XX|CH|INCR options:

Boolean add(K key, V value, double score);
Long add(K key, Set<TypedTuple<V>> tuples);

So how can I use NX|XX|CH|INCR options on Spring data redis with Lettue?

Sorry for my poor english ,Thanks.

1 Answers

Not completely sure if this will 100% work the same for Lettuce. For Jedis, found that we have to use redisTemplate.execute(RedisCallback). A small example of using the ch argument for indicating if any records where changed (opposed to just being added to the sorted set)

redisTemplate.execute(
  (RedisCallback<Long>) connection -> connection.zSetCommands().zAdd(
                        leaderboardKey.getBytes(StandardCharsets.UTF_8),
                        membersToTuples(members),
                        RedisZSetCommands.ZAddArgs.empty().ch()
                )
        )
Related