diff --git a/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java b/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java index b00e22521..5139f158b 100644 --- a/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java +++ b/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java @@ -1276,6 +1276,20 @@ public class RedissonScoredSortedSet extends RedissonExpirable implements RSc return commandExecutor.readAsync(getName(), codec, RedisCommands.SORT_SET, params.toArray()); } + @Override + public Collection readDiff(String... names) { + return get(readDiffAsync(names)); + } + + @Override + public RFuture> readDiffAsync(String... names) { + List args = new ArrayList(names.length + 1); + args.add(names.length + 1); + args.add(getName()); + args.addAll(Arrays.asList(names)); + return commandExecutor.readAsync(getName(), codec, RedisCommands.ZDIFF, args.toArray()); + } + @Override public RFuture takeFirstAsync() { return pollFirstAsync(0, TimeUnit.SECONDS); diff --git a/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java b/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java index 71405ba17..d0eb754d7 100644 --- a/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java +++ b/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java @@ -899,4 +899,15 @@ public interface RScoredSortedSet extends RScoredSortedSetAsync, Iterable< */ Collection readUnion(Aggregate aggregate, Map nameWithWeight); + /** + * Diff ScoredSortedSets specified by name + * with current ScoredSortedSet without state change. + *

+ * Requires Redis 6.2.0 and higher. + * + * @param names - name of sets + * @return result of diff + */ + Collection readDiff(String... names); + } diff --git a/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java b/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java index aa405f949..bdd221724 100644 --- a/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java +++ b/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java @@ -766,4 +766,15 @@ public interface RScoredSortedSetAsync extends RExpirableAsync, RSortableAsyn */ RFuture> readUnionAsync(Aggregate aggregate, Map nameWithWeight); + /** + * Diff ScoredSortedSets specified by name + * with current ScoredSortedSet without state change. + *

+ * Requires Redis 6.2.0 and higher. + * + * @param names - name of sets + * @return result of diff + */ + RFuture> readDiffAsync(String... names); + } diff --git a/redisson/src/main/java/org/redisson/api/RScoredSortedSetReactive.java b/redisson/src/main/java/org/redisson/api/RScoredSortedSetReactive.java index 6ebea73a2..354890422 100644 --- a/redisson/src/main/java/org/redisson/api/RScoredSortedSetReactive.java +++ b/redisson/src/main/java/org/redisson/api/RScoredSortedSetReactive.java @@ -789,6 +789,17 @@ public interface RScoredSortedSetReactive extends RExpirableReactive, RSortab */ Mono> readUnion(Aggregate aggregate, Map nameWithWeight); + /** + * Diff ScoredSortedSets specified by name + * with current ScoredSortedSet without state change. + *

+ * Requires Redis 6.2.0 and higher. + * + * @param names - name of sets + * @return result of diff + */ + Mono> readDiff(String... names); + /** * Removes and returns the head element waiting if necessary for an element to become available. * diff --git a/redisson/src/main/java/org/redisson/api/RScoredSortedSetRx.java b/redisson/src/main/java/org/redisson/api/RScoredSortedSetRx.java index 15c5b823f..cf8cc44bf 100644 --- a/redisson/src/main/java/org/redisson/api/RScoredSortedSetRx.java +++ b/redisson/src/main/java/org/redisson/api/RScoredSortedSetRx.java @@ -791,6 +791,17 @@ public interface RScoredSortedSetRx extends RExpirableRx, RSortableRx> */ Single> readUnion(Aggregate aggregate, Map nameWithWeight); + /** + * Diff ScoredSortedSets specified by name + * with current ScoredSortedSet without state change. + *

+ * Requires Redis 6.2.0 and higher. + * + * @param names - name of sets + * @return result of diff + */ + Single> readDiff(String... names); + /** * Removes and returns the head element waiting if necessary for an element to become available. * diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index 82508e766..4d7a640eb 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -94,6 +94,7 @@ public interface RedisCommands { RedisStrictCommand ASKING = new RedisStrictCommand("ASKING", new VoidReplayConvertor()); RedisStrictCommand READONLY = new RedisStrictCommand("READONLY", new VoidReplayConvertor()); + RedisStrictCommand> ZDIFF = new RedisStrictCommand<>("ZDIFF", new ObjectListReplayDecoder<>()); RedisCommand> ZUNION = new RedisCommand<>("ZUNION", new ObjectListReplayDecoder<>()); RedisCommand> ZINTER = new RedisCommand<>("ZINTER", new ObjectListReplayDecoder<>()); RedisStrictCommand ZUNIONSTORE_INT = new RedisStrictCommand("ZUNIONSTORE", new IntegerReplayConvertor());