Package glide.api.commands
Interface SortedSetBaseCommands
-
- All Known Implementing Classes:
BaseClient,GlideClient,GlideClusterClient
public interface SortedSetBaseCommandsSupports commands for the "Sorted Set Commands" group for standalone and cluster clients.- See Also:
- Sorted Set Commands
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOUNT_VALKEY_APIValkey API keyword used to extract specific count of members from a sorted set.static java.lang.StringLIMIT_VALKEY_APIValkey API keyword used to limit calculation of intersection of sorted sets.static java.lang.StringWITH_SCORE_VALKEY_APIValkey API keyword used to query a sorted set member with its score.static java.lang.StringWITH_SCORES_VALKEY_APIValkey API keyword used to query sorted set members with their scores.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>>bzmpop(GlideString[] keys, ScoreFilter modifier, double timeout)Blocks the connection until it pops and returns a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter).java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>>bzmpop(GlideString[] keys, ScoreFilter modifier, double timeout, long count)Blocks the connection until it pops and returns multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter, long).java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>bzmpop(java.lang.String[] keys, ScoreFilter modifier, double timeout)Blocks the connection until it pops and returns a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter).java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>bzmpop(java.lang.String[] keys, ScoreFilter modifier, double timeout, long count)Blocks the connection until it pops and returns multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter, long).java.util.concurrent.CompletableFuture<java.lang.Object[]>bzpopmax(GlideString[] keys, double timeout)Blocks the connection until it removes and returns a member with the highest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMAXis the blocking variant ofzpopmax(String).java.util.concurrent.CompletableFuture<java.lang.Object[]>bzpopmax(java.lang.String[] keys, double timeout)Blocks the connection until it removes and returns a member with the highest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMAXis the blocking variant ofzpopmax(String).java.util.concurrent.CompletableFuture<java.lang.Object[]>bzpopmin(GlideString[] keys, double timeout)Blocks the connection until it removes and returns a member with the lowest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMINis the blocking variant ofzpopmin(String).java.util.concurrent.CompletableFuture<java.lang.Object[]>bzpopmin(java.lang.String[] keys, double timeout)Blocks the connection until it removes and returns a member with the lowest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMINis the blocking variant ofzpopmin(String).java.util.concurrent.CompletableFuture<java.lang.Long>zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap, ZAddOptions options)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap, ZAddOptions options, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap, ZAddOptions options)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Long>zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap, ZAddOptions options, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.java.util.concurrent.CompletableFuture<java.lang.Double>zaddIncr(GlideString key, GlideString member, double increment)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.java.util.concurrent.CompletableFuture<java.lang.Double>zaddIncr(GlideString key, GlideString member, double increment, ZAddOptions options)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts aszincrby(GlideString, double, GlideString).java.util.concurrent.CompletableFuture<java.lang.Double>zaddIncr(java.lang.String key, java.lang.String member, double increment)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts aszincrby(GlideString, double, GlideString).java.util.concurrent.CompletableFuture<java.lang.Double>zaddIncr(java.lang.String key, java.lang.String member, double increment, ZAddOptions options)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts aszincrby(String, double, String).java.util.concurrent.CompletableFuture<java.lang.Long>zcard(GlideString key)Returns the cardinality (number of elements) of the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>zcard(java.lang.String key)Returns the cardinality (number of elements) of the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>zcount(GlideString key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)Returns the number of members in the sorted set stored atkeywith scores betweenminScoreandmaxScore.java.util.concurrent.CompletableFuture<java.lang.Long>zcount(java.lang.String key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)Returns the number of members in the sorted set stored atkeywith scores betweenminScoreandmaxScore.java.util.concurrent.CompletableFuture<GlideString[]>zdiff(GlideString[] keys)Returns the difference between the first sorted set and all the successive sorted sets.
To get the elements with their scores, seezdiffWithScores(java.lang.String[]).java.util.concurrent.CompletableFuture<java.lang.String[]>zdiff(java.lang.String[] keys)Returns the difference between the first sorted set and all the successive sorted sets.
To get the elements with their scores, seezdiffWithScores(java.lang.String[]).java.util.concurrent.CompletableFuture<java.lang.Long>zdiffstore(GlideString destination, GlideString[] keys)Calculates the difference between the first sorted set and all the successive sorted sets atkeysand stores the difference as a sorted set todestination, overwriting it if it already exists.java.util.concurrent.CompletableFuture<java.lang.Long>zdiffstore(java.lang.String destination, java.lang.String[] keys)Calculates the difference between the first sorted set and all the successive sorted sets atkeysand stores the difference as a sorted set todestination, overwriting it if it already exists.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zdiffWithScores(GlideString[] keys)Returns the difference between the first sorted set and all the successive sorted sets.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zdiffWithScores(java.lang.String[] keys)Returns the difference between the first sorted set and all the successive sorted sets.java.util.concurrent.CompletableFuture<java.lang.Double>zincrby(GlideString key, double increment, GlideString member)Increments the score ofmemberin the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score.java.util.concurrent.CompletableFuture<java.lang.Double>zincrby(java.lang.String key, double increment, java.lang.String member)Increments the score ofmemberin the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score.java.util.concurrent.CompletableFuture<java.lang.String[]>zinter(WeightAggregateOptions.KeyArray keys)Returns the intersection of members from sorted sets specified by the givenkeys.java.util.concurrent.CompletableFuture<GlideString[]>zinter(WeightAggregateOptions.KeyArrayBinary keys)Returns the intersection of members from sorted sets specified by the givenkeys.java.util.concurrent.CompletableFuture<java.lang.Long>zintercard(GlideString[] keys)Returns the cardinality of the intersection of the sorted sets specified bykeys.java.util.concurrent.CompletableFuture<java.lang.Long>zintercard(GlideString[] keys, long limit)Returns the cardinality of the intersection of the sorted sets specified bykeys.java.util.concurrent.CompletableFuture<java.lang.Long>zintercard(java.lang.String[] keys)Returns the cardinality of the intersection of the sorted sets specified bykeys.java.util.concurrent.CompletableFuture<java.lang.Long>zintercard(java.lang.String[] keys, long limit)Returns the cardinality of the intersection of the sorted sets specified bykeys.java.util.concurrent.CompletableFuture<java.lang.Long>zinterstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.lang.Long>zinterstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.lang.Long>zinterstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.lang.Long>zinterstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.java.util.concurrent.CompletableFuture<java.lang.Long>zlexcount(GlideString key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)Returns the number of members in the sorted set stored atkeywith scores betweenminLexandmaxLex.java.util.concurrent.CompletableFuture<java.lang.Long>zlexcount(java.lang.String key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)Returns the number of members in the sorted set stored atkeywith scores betweenminLexandmaxLex.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>>zmpop(GlideString[] keys, ScoreFilter modifier)Pops a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>>zmpop(GlideString[] keys, ScoreFilter modifier, long count)Pops multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>zmpop(java.lang.String[] keys, ScoreFilter modifier)Pops a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>zmpop(java.lang.String[] keys, ScoreFilter modifier, long count)Pops multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.java.util.concurrent.CompletableFuture<java.lang.Double[]>zmscore(GlideString key, GlideString[] members)Returns the scores associated with the specifiedmembersin the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Double[]>zmscore(java.lang.String key, java.lang.String[] members)Returns the scores associated with the specifiedmembersin the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zpopmax(GlideString key)Removes and returns the member with the highest score from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zpopmax(GlideString key, long count)Removes and returns up tocountmembers with the highest scores from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zpopmax(java.lang.String key)Removes and returns the member with the highest score from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zpopmax(java.lang.String key, long count)Removes and returns up tocountmembers with the highest scores from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zpopmin(GlideString key)Removes and returns the member with the lowest score from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zpopmin(GlideString key, long count)Removes and returns up tocountmembers with the lowest scores from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zpopmin(java.lang.String key)Removes and returns the member with the lowest score from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zpopmin(java.lang.String key, long count)Removes and returns up tocountmembers with the lowest scores from the sorted set stored at the specifiedkey.java.util.concurrent.CompletableFuture<GlideString>zrandmember(GlideString key)Returns a random element from the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.String>zrandmember(java.lang.String key)Returns a random element from the sorted set stored atkey.java.util.concurrent.CompletableFuture<GlideString[]>zrandmemberWithCount(GlideString key, long count)Retrieves random elements from the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.String[]>zrandmemberWithCount(java.lang.String key, long count)Returns a random element from the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Object[][]>zrandmemberWithCountWithScores(GlideString key, long count)Retrieves random elements along with their scores from the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Object[][]>zrandmemberWithCountWithScores(java.lang.String key, long count)Retrieves random elements along with their scores from the sorted set stored atkey.java.util.concurrent.CompletableFuture<GlideString[]>zrange(GlideString key, RangeOptions.RangeQuery rangeQuery)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).java.util.concurrent.CompletableFuture<GlideString[]>zrange(GlideString key, RangeOptions.RangeQuery rangeQuery, boolean reverse)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).java.util.concurrent.CompletableFuture<java.lang.String[]>zrange(java.lang.String key, RangeOptions.RangeQuery rangeQuery)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).java.util.concurrent.CompletableFuture<java.lang.String[]>zrange(java.lang.String key, RangeOptions.RangeQuery rangeQuery, boolean reverse)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).java.util.concurrent.CompletableFuture<java.lang.Long>zrangestore(GlideString destination, GlideString source, RangeOptions.RangeQuery rangeQuery)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination.java.util.concurrent.CompletableFuture<java.lang.Long>zrangestore(GlideString destination, GlideString source, RangeOptions.RangeQuery rangeQuery, boolean reverse)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination.java.util.concurrent.CompletableFuture<java.lang.Long>zrangestore(java.lang.String destination, java.lang.String source, RangeOptions.RangeQuery rangeQuery)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination.java.util.concurrent.CompletableFuture<java.lang.Long>zrangestore(java.lang.String destination, java.lang.String source, RangeOptions.RangeQuery rangeQuery, boolean reverse)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zrangeWithScores(GlideString key, RangeOptions.ScoredRangeQuery rangeQuery)Returns the specified range of elements with their scores in the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zrangeWithScores(GlideString key, RangeOptions.ScoredRangeQuery rangeQuery, boolean reverse)Returns the specified range of elements with their scores in the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zrangeWithScores(java.lang.String key, RangeOptions.ScoredRangeQuery rangeQuery)Returns the specified range of elements with their scores in the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zrangeWithScores(java.lang.String key, RangeOptions.ScoredRangeQuery rangeQuery, boolean reverse)Returns the specified range of elements with their scores in the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>zrank(GlideString key, GlideString member)Returns the rank ofmemberin the sorted set stored atkey, with scores ordered from low to high, starting from0.
To get the rank ofmemberwith its score, seezrankWithScore(java.lang.String, java.lang.String).java.util.concurrent.CompletableFuture<java.lang.Long>zrank(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkey, with scores ordered from low to high, starting from0.
To get the rank ofmemberwith its score, seezrankWithScore(java.lang.String, java.lang.String).java.util.concurrent.CompletableFuture<java.lang.Object[]>zrankWithScore(GlideString key, GlideString member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the lowest to highest, starting from0.java.util.concurrent.CompletableFuture<java.lang.Object[]>zrankWithScore(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the lowest to highest, starting from0.java.util.concurrent.CompletableFuture<java.lang.Long>zrem(GlideString key, GlideString[] members)Removes the specified members from the sorted set stored atkey.
Specified members that are not a member of this set are ignored.java.util.concurrent.CompletableFuture<java.lang.Long>zrem(java.lang.String key, java.lang.String[] members)Removes the specified members from the sorted set stored atkey.
Specified members that are not a member of this set are ignored.java.util.concurrent.CompletableFuture<java.lang.Long>zremrangebylex(GlideString key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)Removes all elements in the sorted set stored atkeywith a lexicographical order betweenminLexandmaxLex.java.util.concurrent.CompletableFuture<java.lang.Long>zremrangebylex(java.lang.String key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)Removes all elements in the sorted set stored atkeywith a lexicographical order betweenminLexandmaxLex.java.util.concurrent.CompletableFuture<java.lang.Long>zremrangebyrank(GlideString key, long start, long end)Removes all elements in the sorted set stored atkeywith rank betweenstartandend.java.util.concurrent.CompletableFuture<java.lang.Long>zremrangebyrank(java.lang.String key, long start, long end)Removes all elements in the sorted set stored atkeywith rank betweenstartandend.java.util.concurrent.CompletableFuture<java.lang.Long>zremrangebyscore(GlideString key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)Removes all elements in the sorted set stored atkeywith a score betweenminScoreandmaxScore.java.util.concurrent.CompletableFuture<java.lang.Long>zremrangebyscore(java.lang.String key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)Removes all elements in the sorted set stored atkeywith a score betweenminScoreandmaxScore.java.util.concurrent.CompletableFuture<java.lang.Long>zrevrank(GlideString key, GlideString member)Returns the rank ofmemberin the sorted set stored atkey, where scores are ordered from the highest to lowest, starting from0.
To get the rank ofmemberwith its score, seezrevrankWithScore(java.lang.String, java.lang.String).java.util.concurrent.CompletableFuture<java.lang.Long>zrevrank(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkey, where scores are ordered from the highest to lowest, starting from0.
To get the rank ofmemberwith its score, seezrevrankWithScore(java.lang.String, java.lang.String).java.util.concurrent.CompletableFuture<java.lang.Object[]>zrevrankWithScore(GlideString key, GlideString member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the highest to lowest, starting from0.java.util.concurrent.CompletableFuture<java.lang.Object[]>zrevrankWithScore(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the highest to lowest, starting from0.java.util.concurrent.CompletableFuture<java.lang.Object[]>zscan(GlideString key, GlideString cursor)Iterates incrementally over a sorted set.java.util.concurrent.CompletableFuture<java.lang.Object[]>zscan(GlideString key, GlideString cursor, ZScanOptionsBinary zScanOptions)Iterates incrementally over a sorted set.java.util.concurrent.CompletableFuture<java.lang.Object[]>zscan(java.lang.String key, java.lang.String cursor)Iterates incrementally over a sorted set.java.util.concurrent.CompletableFuture<java.lang.Object[]>zscan(java.lang.String key, java.lang.String cursor, ZScanOptions zScanOptions)Iterates incrementally over a sorted set.java.util.concurrent.CompletableFuture<java.lang.Double>zscore(GlideString key, GlideString member)Returns the score ofmemberin the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.Double>zscore(java.lang.String key, java.lang.String member)Returns the score ofmemberin the sorted set stored atkey.java.util.concurrent.CompletableFuture<java.lang.String[]>zunion(WeightAggregateOptions.KeyArray keys)Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).java.util.concurrent.CompletableFuture<GlideString[]>zunion(WeightAggregateOptions.KeyArrayBinary keys)Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).java.util.concurrent.CompletableFuture<java.lang.Long>zunionstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.lang.Long>zunionstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.lang.Long>zunionstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.lang.Long>zunionstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>>zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>>zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
-
-
-
Field Detail
-
WITH_SCORES_VALKEY_API
static final java.lang.String WITH_SCORES_VALKEY_API
Valkey API keyword used to query sorted set members with their scores.- See Also:
- Constant Field Values
-
WITH_SCORE_VALKEY_API
static final java.lang.String WITH_SCORE_VALKEY_API
Valkey API keyword used to query a sorted set member with its score.- See Also:
- Constant Field Values
-
COUNT_VALKEY_API
static final java.lang.String COUNT_VALKEY_API
Valkey API keyword used to extract specific count of members from a sorted set.- See Also:
- Constant Field Values
-
LIMIT_VALKEY_API
static final java.lang.String LIMIT_VALKEY_API
Valkey API keyword used to limit calculation of intersection of sorted sets.- See Also:
- Constant Field Values
-
-
Method Detail
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap, ZAddOptions options, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.options- The ZAdd options.changed- Modify the return value from the number of new elements added, to the total number of elements changed.- Returns:
- The number of elements added to the sorted set.
Ifchangedis set, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
- Example:
ZaddOptions options = ZaddOptions.builder().conditionalChange(ONLY_IF_DOES_NOT_EXIST).build(); Long num = client.zadd("mySortedSet", Map.of("member1", 10.5, "member2", 8.2), options, false).get(); assert num == 2L; // Indicates that two elements have been added or updated in the sorted set "mySortedSet". options = ZaddOptions.builder().conditionalChange(ONLY_IF_EXISTS).build(); Long num = client.zadd("existingSortedSet", Map.of("member1", 15.0, "member2", 5.5), options, false).get(); assert num == 2L; // Updates the scores of two existing members in the sorted set "existingSortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap, ZAddOptions options, boolean changed)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.options- The ZAdd options.changed- Modify the return value from the number of new elements added, to the total number of elements changed.- Returns:
- The number of elements added to the sorted set.
Ifchangedis set, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
- Example:
ZaddOptions options = ZaddOptions.builder().conditionalChange(ONLY_IF_DOES_NOT_EXIST).build(); Long num = client.zadd(gs("mySortedSet"), Map.of(gs("member1"), 10.5, gs("member2"), 8.2), options, false).get(); assert num == 2L; // Indicates that two elements have been to the sorted set "mySortedSet". options = ZaddOptions.builder().conditionalChange(ONLY_IF_EXISTS).build(); Long num = client.zadd(gs("existingSortedSet"), Map.of(gs("member1"), 15.0, gs("member2"), 5.5), options, false).get(); assert num == 2L; // Updates the scores of two existing members in the sorted set "existingSortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap, ZAddOptions options)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.options- The ZAdd options.- Returns:
- The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
- Example:
ZaddOptions options = ZaddOptions.builder().conditionalChange(ONLY_IF_DOES_NOT_EXIST).build(); Long num = client.zadd("mySortedSet", Map.of("member1", 10.5, "member2", 8.2), options).get(); assert num == 2L; // Indicates that two elements have been added to the sorted set "mySortedSet". options = ZaddOptions.builder().conditionalChange(ONLY_IF_EXISTS).build(); Long num = client.zadd("existingSortedSet", Map.of("member1", 15.0, "member2", 5.5), options).get(); assert num == 0L; // No new members were added to the sorted set "existingSortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap, ZAddOptions options)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.options- The ZAdd options.- Returns:
- The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
- Example:
ZaddOptions options = ZaddOptions.builder().conditionalChange(ONLY_IF_DOES_NOT_EXIST).build(); Long num = client.zadd(gs("mySortedSet"), Map.of(gs("member1"), 10.5, gs("member2"), 8.2), options).get(); assert num == 2L; // Indicates that two elements have been added to the sorted set "mySortedSet". options = ZaddOptions.builder().conditionalChange(ONLY_IF_EXISTS).build(); Long num = client.zadd(gs("existingSortedSet"), Map.of(gs("member1"), 15.0, gs("member2"), 5.5), options).get(); assert num == 0L; // No new members were added to the sorted set "existingSortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap, boolean changed)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.changed- Modify the return value from the number of new elements added, to the total number of elements changed.- Returns:
- The number of elements added to the sorted set.
Ifchangedis set, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
- Example:
Long num = client.zadd("mySortedSet", Map.of("member1", 10.5, "member2", 8.2), true).get(); assert num == 2L; // Indicates that two elements have been added or updated in the sorted set "mySortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap, boolean changed)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.changed- Modify the return value from the number of new elements added, to the total number of elements changed.- Returns:
- The number of elements added to the sorted set.
Ifchangedis set, returns the number of elements updated in the sorted set. - See Also:
- valkey.io for more details.
- Example:
Long num = client.zadd(gs("mySortedSet"), Map.of(gs("member1"), 10.5, gs("member2"), 8.2), true).get(); assert num == 2L; // Indicates that two elements have been added or updated in the sorted set "mySortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(java.lang.String key, java.util.Map<java.lang.String,java.lang.Double> membersScoresMap)Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.- Returns:
- The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
- Example:
Long num = client.zadd("mySortedSet", Map.of("member1", 10.5, "member2", 8.2)).get(); assert num == 2L; // Indicates that two elements have been added to the sorted set "mySortedSet".
-
zadd
java.util.concurrent.CompletableFuture<java.lang.Long> zadd(GlideString key, java.util.Map<GlideString,java.lang.Double> membersScoresMap)
Adds members with their scores to the sorted set stored atkey.
If a member is already a part of the sorted set, its score is updated.- Parameters:
key- The key of the sorted set.membersScoresMap- AMapof members to their corresponding scores.- Returns:
- The number of elements added to the sorted set.
- See Also:
- valkey.io for more details.
- Example:
Long num = client.zadd(gs("mySortedSet"), Map.of(gs("member1"), 10.5, gs("member2"), 8.2)).get(); assert num == 2L; // Indicates that two elements have been added to the sorted set "mySortedSet".
-
zaddIncr
java.util.concurrent.CompletableFuture<java.lang.Double> zaddIncr(java.lang.String key, java.lang.String member, double increment, ZAddOptions options)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts aszincrby(String, double, String).- Parameters:
key- The key of the sorted set.member- A member in the sorted set to increment.increment- The score to increment the member.options- The ZAdd options.- Returns:
- The score of the member.
If there was a conflict with the options, the operation aborts andnullis returned. - See Also:
- valkey.io for more details.
- Example:
ZAddOptions options = ZaddOptions.builder().conditionalChange(ONLY_IF_DOES_NOT_EXIST).build(); Double num = client.zaddIncr("mySortedSet", member, 5.0, options).get(); assert num == 5.0; options = ZAddOptions.builder().updateOptions(SCORE_LESS_THAN_CURRENT).build(); Double num = client.zaddIncr("existingSortedSet", member, 3.0, options).get(); assert num == null;
-
zaddIncr
java.util.concurrent.CompletableFuture<java.lang.Double> zaddIncr(GlideString key, GlideString member, double increment, ZAddOptions options)
Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts aszincrby(GlideString, double, GlideString).- Parameters:
key- The key of the sorted set.member- A member in the sorted set to increment.increment- The score to increment the member.options- The ZAdd options.- Returns:
- The score of the member.
If there was a conflict with the options, the operation aborts andnullis returned. - See Also:
- valkey.io for more details.
- Example:
ZAddOptions options = ZaddOptions.builder().conditionalChange(ONLY_IF_DOES_NOT_EXIST).build(); Double num = client.zaddIncr(gs("mySortedSet"), member, 5.0, options).get(); assert num == 5.0; options = ZAddOptions.builder().updateOptions(SCORE_LESS_THAN_CURRENT).build(); Double num = client.zaddIncr(gs("existingSortedSet"), member, 3.0, options).get(); assert num == null;
-
zaddIncr
java.util.concurrent.CompletableFuture<java.lang.Double> zaddIncr(java.lang.String key, java.lang.String member, double increment)Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.
zaddIncrwith empty option acts aszincrby(GlideString, double, GlideString).- Parameters:
key- The key of the sorted set.member- A member in the sorted set to increment.increment- The score to increment the member.- Returns:
- The score of the member.
- See Also:
- valkey.io for more details.
- Example:
Double num = client.zaddIncr("mySortedSet", member, 5.0).get(); assert num == 5.0;
-
zaddIncr
java.util.concurrent.CompletableFuture<java.lang.Double> zaddIncr(GlideString key, GlideString member, double increment)
Increments the score of member in the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score (as if its previous score was0.0).
Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.- Parameters:
key- The key of the sorted set.member- A member in the sorted set to increment.increment- The score to increment the member.- Returns:
- The score of the member.
- See Also:
- valkey.io for more details.
- Example:
Double num = client.zaddIncr(gs("mySortedSet"), member, 5.0).get(); assert num == 5.0;
-
zrem
java.util.concurrent.CompletableFuture<java.lang.Long> zrem(java.lang.String key, java.lang.String[] members)Removes the specified members from the sorted set stored atkey.
Specified members that are not a member of this set are ignored.- Parameters:
key- The key of the sorted set.members- An array of members to remove from the sorted set.- Returns:
- The number of members that were removed from the sorted set, not including non-existing
members.
Ifkeydoes not exist, it is treated as an empty sorted set, and this command returns0. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zrem("mySortedSet", new String[] {"member1", "member2"}).get(); assert num1 == 2L; // Indicates that two members have been removed from the sorted set "mySortedSet". Long num2 = client.zrem("nonExistingSortedSet", new String[] {"member1", "member2"}).get(); assert num2 == 0L; // Indicates that no members were removed as the sorted set "nonExistingSortedSet" does not exist.
-
zrem
java.util.concurrent.CompletableFuture<java.lang.Long> zrem(GlideString key, GlideString[] members)
Removes the specified members from the sorted set stored atkey.
Specified members that are not a member of this set are ignored.- Parameters:
key- The key of the sorted set.members- An array of members to remove from the sorted set.- Returns:
- The number of members that were removed from the sorted set, not including non-existing
members.
Ifkeydoes not exist, it is treated as an empty sorted set, and this command returns0. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zrem(gs("mySortedSet"), new GlideString[] {gs("member1"), gs("member2")}).get(); assert num1 == 2L; // Indicates that two members have been removed from the sorted set "mySortedSet". Long num2 = client.zrem(gs("nonExistingSortedSet"), new GlideString[] {gs("member1"), gs("member2")}).get(); assert num2 == 0L; // Indicates that no members were removed as the sorted set "nonExistingSortedSet" does not exist.
-
zcard
java.util.concurrent.CompletableFuture<java.lang.Long> zcard(java.lang.String key)
Returns the cardinality (number of elements) of the sorted set stored atkey.- Parameters:
key- The key of the sorted set.- Returns:
- The number of elements in the sorted set.
Ifkeydoes not exist, it is treated as an empty sorted set, and this command return0. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zcard("mySortedSet").get(); assert num1 == 3L; // Indicates that there are 3 elements in the sorted set "mySortedSet". Long num2 = client.zcard("nonExistingSortedSet").get(); assert num2 == 0L;
-
zcard
java.util.concurrent.CompletableFuture<java.lang.Long> zcard(GlideString key)
Returns the cardinality (number of elements) of the sorted set stored atkey.- Parameters:
key- The key of the sorted set.- Returns:
- The number of elements in the sorted set.
Ifkeydoes not exist, it is treated as an empty sorted set, and this command return0. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zcard(gs("mySortedSet")).get(); assert num1 == 3L; // Indicates that there are 3 elements in the sorted set "mySortedSet". Long num2 = client.zcard((gs("nonExistingSortedSet")).get(); assert num2 == 0L;
-
zpopmin
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zpopmin(java.lang.String key, long count)Removes and returns up tocountmembers with the lowest scores from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.count- Specifies the quantity of members to pop.
Ifcountis higher than the sorted set's cardinality, returns all members and their scores, ordered from lowest to highest.- Returns:
- A map of the removed members and their scores, ordered from the one with the lowest
score to the one with the highest.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<String, Double> payload = client.zpopmax("mySortedSet", 2).get(); assert payload.equals(Map.of("member3", 7.5 , "member2", 8.0)); // Indicates that "member3" with a score of 7.5 and "member2" with a score of 8.0 have been removed from the sorted set.
-
zpopmin
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zpopmin(GlideString key, long count)
Removes and returns up tocountmembers with the lowest scores from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.count- Specifies the quantity of members to pop.
Ifcountis higher than the sorted set's cardinality, returns all members and their scores, ordered from lowest to highest.- Returns:
- A map of the removed members and their scores, ordered from the one with the lowest
score to the one with the highest.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Double> payload = client.zpopmax(gs("mySortedSet"), 2).get(); assert payload.equals(Map.of(gs("member3"), 7.5, gs("member2"), 8.0)); // Indicates that gs("member3") with a score of 7.5 and gs("member2") with a score of 8.0 have been removed from the sorted set.
-
zpopmin
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zpopmin(java.lang.String key)
Removes and returns the member with the lowest score from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.- Returns:
- A map containing the removed member and its corresponding score.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<String, Double> payload = client.zpopmin("mySortedSet").get(); assert payload.equals(Map.of("member1", 5.0)); // Indicates that "member1" with a score of 5.0 has been removed from the sorted set.
-
zpopmin
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zpopmin(GlideString key)
Removes and returns the member with the lowest score from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.- Returns:
- A map containing the removed member and its corresponding score.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Double> payload = client.zpopmin(gs("mySortedSet")).get(); assert payload.equals(Map.of(gs("member1"), 5.0)); // Indicates that gs("member1") with a score of 5.0 has been removed from the sorted set.
-
bzpopmin
java.util.concurrent.CompletableFuture<java.lang.Object[]> bzpopmin(java.lang.String[] keys, double timeout)Blocks the connection until it removes and returns a member with the lowest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMINis the blocking variant ofzpopmin(String).- Parameters:
keys- The keys of the sorted sets.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- An
arraycontaining the key where the member was popped out, the member itself, and the member score.
If no member could be popped and thetimeoutexpired, returnsnull. - See Also:
- valkey.io for more details.
- Example:
Object[] data = client.bzpopmin(new String[] {"zset1", "zset2"}, 0.5).get(); System.out.printf("Popped '%s' with score %d from sorted set '%s'%n", data[1], data[2], data[0]);
-
bzpopmin
java.util.concurrent.CompletableFuture<java.lang.Object[]> bzpopmin(GlideString[] keys, double timeout)
Blocks the connection until it removes and returns a member with the lowest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMINis the blocking variant ofzpopmin(String).- Parameters:
keys- The keys of the sorted sets.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- An
arraycontaining the key where the member was popped out, the member itself, and the member score.
If no member could be popped and thetimeoutexpired, returnsnull. - See Also:
- valkey.io for more details.
- Example:
Object[] data = client.bzpopmin(new GlideString[] {gs("zset1"), gs("zset2")}, 0.5).get(); System.out.printf("Popped '%s' with score %d from sorted set '%s'%n", data[1], data[2], data[0]);
-
zpopmax
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zpopmax(java.lang.String key, long count)Removes and returns up tocountmembers with the highest scores from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.count- Specifies the quantity of members to pop.
Ifcountis higher than the sorted set's cardinality, returns all members and their scores, ordered from highest to lowest.- Returns:
- A map of the removed members and their scores, ordered from the one with the highest
score to the one with the lowest.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<String, Double> payload = client.zpopmax("mySortedSet", 2).get(); assert payload.equals(Map.of("member2", 8.0, "member3", 7.5)); // Indicates that "member2" with a score of 8.0 and "member3" with a score of 7.5 have been removed from the sorted set.
-
zpopmax
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zpopmax(GlideString key, long count)
Removes and returns up tocountmembers with the highest scores from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.count- Specifies the quantity of members to pop.
Ifcountis higher than the sorted set's cardinality, returns all members and their scores, ordered from highest to lowest.- Returns:
- A map of the removed members and their scores, ordered from the one with the highest
score to the one with the lowest.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Double> payload = client.zpopmax(gs("mySortedSet"), 2).get(); assert payload.equals(Map.of(gs("member2"), 8.0, gs("member3"), 7.5)); // Indicates that gs("member2") with a score of 8.0 and gs("member3") with a score of 7.5 have been removed from the sorted set.
-
zpopmax
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zpopmax(java.lang.String key)
Removes and returns the member with the highest score from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.- Returns:
- A map containing the removed member and its corresponding score.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<String, Double> payload = client.zpopmax("mySortedSet").get(); assert payload.equals(Map.of("member1", 10.0)); // Indicates that "member1" with a score of 10.0 has been removed from the sorted set.
-
zpopmax
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zpopmax(GlideString key)
Removes and returns the member with the highest score from the sorted set stored at the specifiedkey.- Parameters:
key- The key of the sorted set.- Returns:
- A map containing the removed member and its corresponding score.
Ifkeydoesn't exist, it will be treated as an empty sorted set and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Double> payload = client.zpopmax(gs("mySortedSet")).get(); assert payload.equals(Map.of(gs("member1"), 10.0)); // Indicates that gs("member1") with a score of 10.0 has been removed from the sorted set.
-
bzpopmax
java.util.concurrent.CompletableFuture<java.lang.Object[]> bzpopmax(java.lang.String[] keys, double timeout)Blocks the connection until it removes and returns a member with the highest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMAXis the blocking variant ofzpopmax(String).- Parameters:
keys- The keys of the sorted sets.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- An
arraycontaining the key where the member was popped out, the member itself, and the member score.
If no member could be popped and thetimeoutexpired, returnsnull. - See Also:
- valkey.io for more details.
- Example:
Object[] data = client.bzpopmax(new String[] {"zset1", "zset2"}, 0.5).get(); System.out.printf("Popped '%s' with score %d from sorted set '%s'%n", data[1], data[2], data[0]);
-
bzpopmax
java.util.concurrent.CompletableFuture<java.lang.Object[]> bzpopmax(GlideString[] keys, double timeout)
Blocks the connection until it removes and returns a member with the highest score from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZPOPMAXis the blocking variant ofzpopmax(String).- Parameters:
keys- The keys of the sorted sets.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- An
arraycontaining the key where the member was popped out, the member itself, and the member score.
If no member could be popped and thetimeoutexpired, returnsnull. - See Also:
- valkey.io for more details.
- Example:
Object[] data = client.bzpopmax(new GlideString[] {gs("zset1"), gs("zset2")}, 0.5).get(); System.out.printf("Popped '%s' with score %d from sorted set '%s'%n", data[1], data[2], data[0]);
-
zscore
java.util.concurrent.CompletableFuture<java.lang.Double> zscore(java.lang.String key, java.lang.String member)Returns the score ofmemberin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.member- The member whose score is to be retrieved.- Returns:
- The score of the member.
Ifmemberdoes not exist in the sorted set,nullis returned.
Ifkeydoes not exist,nullis returned. - See Also:
- valkey.io for more details.
- Example:
Double num1 = client.zscore("mySortedSet", "member").get(); assert num1 == 10.5; // Indicates that the score of "member" in the sorted set "mySortedSet" is 10.5. Double num2 = client.zscore("mySortedSet", "nonExistingMember").get(); assert num2 == null;
-
zscore
java.util.concurrent.CompletableFuture<java.lang.Double> zscore(GlideString key, GlideString member)
Returns the score ofmemberin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.member- The member whose score is to be retrieved.- Returns:
- The score of the member.
Ifmemberdoes not exist in the sorted set,nullis returned.
Ifkeydoes not exist,nullis returned. - See Also:
- valkey.io for more details.
- Example:
Double num1 = client.zscore(gs("mySortedSet")), gs("member")).get(); assert num1 == 10.5; // Indicates that the score of "member" in the sorted set "mySortedSet" is 10.5. Double num2 = client.zscore(gs("mySortedSet"), gs("nonExistingMember")).get(); assert num2 == null;
-
zrange
java.util.concurrent.CompletableFuture<java.lang.String[]> zrange(java.lang.String key, RangeOptions.RangeQuery rangeQuery, boolean reverse)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- If true, reverses the sorted set, with index 0 as the element with the highest score.- Returns:
- An array of elements within the specified range. If
keydoes not exist, it is treated as an empty sorted set, and the command returns an empty array. - See Also:
- valkey.io for more details.
- Example:
RangeByScore query1 = new RangeByScore(new ScoreBoundary(10), new ScoreBoundary(20)); String[] payload1 = client.zrange("mySortedSet", query1, true).get(); // Returns members with scores between 10 and 20. assert payload1.equals(new String[] {"member3", "member2", "member1"}); // Returns all members in descending order. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); String[] payload2 = client.zrange("mySortedSet", query2, false).get(); assert payload2.equals(new String[] {"member2", "member3"}); // Returns members with scores within the range of negative infinity to 3, in ascending order.
-
zrange
java.util.concurrent.CompletableFuture<GlideString[]> zrange(GlideString key, RangeOptions.RangeQuery rangeQuery, boolean reverse)
Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- If true, reverses the sorted set, with index 0 as the element with the highest score.- Returns:
- An array of elements within the specified range. If
keydoes not exist, it is treated as an empty sorted set, and the command returns an empty array. - See Also:
- valkey.io for more details.
- Example:
RangeByScore query1 = new RangeByScore(new ScoreBoundary(10), new ScoreBoundary(20)); GlideString[] payload1 = client.zrange(gs("mySortedSet"), query1, true).get(); // Returns members with scores between 10 and 20. assert Arrays.equals(payload1, new GlideString[] {gs("member3"), gs("member2"), gs("member1")}); // Returns all members in descending order. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); GlideString[] payload2 = client.zrange(gs("mySortedSet"), query2, false).get(); assert Arrays.equals(payload2, new GlideString[] {gs("member2"), gs("member3")}); // Returns members with scores within the range of negative infinity to 3, in ascending order.
-
zrange
java.util.concurrent.CompletableFuture<java.lang.String[]> zrange(java.lang.String key, RangeOptions.RangeQuery rangeQuery)Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- An of array elements within the specified range. If
keydoes not exist, it is treated as an empty sorted set, and the command returns an empty array. - See Also:
- valkey.io for more details.
- Example:
RangeByIndex query1 = new RangeByIndex(0, -1); String[] payload1 = client.zrange("mySortedSet",query1).get(); assert payload1.equals(new String[] {"member1", "member2", "member3"}); // Returns all members in ascending order. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); String[] payload2 = client.zrange("mySortedSet", query2).get(); assert payload2.equals(new String[] {"member2", "member3"}); // Returns members with scores within the range of negative infinity to 3, in ascending order.
-
zrange
java.util.concurrent.CompletableFuture<GlideString[]> zrange(GlideString key, RangeOptions.RangeQuery rangeQuery)
Returns the specified range of elements in the sorted set stored atkey.
ZRANGEcan perform different types of range queries: by index (rank), by the score, or by lexicographical order.
To get the elements with their scores, seezrangeWithScores(java.lang.String, glide.api.models.commands.RangeOptions.ScoredRangeQuery, boolean).- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- An of array elements within the specified range. If
keydoes not exist, it is treated as an empty sorted set, and the command returns an empty array. - See Also:
- valkey.io for more details.
- Example:
RangeByIndex query1 = new RangeByIndex(0, -1); GlideString[] payload1 = client.zrange(gs("mySortedSet"),query1).get(); assert payload1.equals(new GlideString[] {gs("member1") , gs("member2") , gs("member3") }); // Returns all members in ascending order. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); GlideString[] payload2 = client.zrange(gs("mySortedSet"), query2).get(); assert Arrays.equals(payload2, new GlideString[] {gs("member2"), gs("member3")}); // Returns members with scores within the range of negative infinity to 3, in ascending order.
-
zrangeWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zrangeWithScores(java.lang.String key, RangeOptions.ScoredRangeQuery rangeQuery, boolean reverse)Returns the specified range of elements with their scores in the sorted set stored atkey. Similar tozrange(java.lang.String, glide.api.models.commands.RangeOptions.RangeQuery, boolean)but with aWITHSCOREflag.- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- If true, reverses the sorted set, with index 0 as the element with the highest score.- Returns:
- A
Mapof elements and their scores within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
RangeByScore query1 = new RangeByScore(new ScoreBoundary(10), new ScoreBoundary(20)); Map<String, Double> payload1 = client.zrangeWithScores("mySortedSet", query1, true).get(); assert payload1.equals(Map.of("member2", 15.2, "member1", 10.5)); // Returns members with scores between 10 and 20 (inclusive) with their scores. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); Map<String, Double> payload2 = client.zrangeWithScores("mySortedSet", query2, false).get(); assert payload2.equals(Map.of("member4", -2.0, "member7", 1.5)); // Returns members with with scores within the range of negative infinity to 3, with their scores.
-
zrangeWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zrangeWithScores(GlideString key, RangeOptions.ScoredRangeQuery rangeQuery, boolean reverse)
Returns the specified range of elements with their scores in the sorted set stored atkey. Similar tozrange(java.lang.String, glide.api.models.commands.RangeOptions.RangeQuery, boolean)but with aWITHSCOREflag.- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- If true, reverses the sorted set, with index 0 as the element with the highest score.- Returns:
- A
Mapof elements and their scores within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
RangeByScore query1 = new RangeByScore(new ScoreBoundary(10), new ScoreBoundary(20)); Map<GlideString, Double> payload1 = client.zrangeWithScores(gs("mySortedSet"), query1, true).get(); assert payload1.equals(Map.of(gs("member2"), 15.2, gs("member1"), 10.5)); // Returns members with scores between 10 and 20 (inclusive) with their scores. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); Map<GlideString, Double> payload2 = client.zrangeWithScores(gs("mySortedSet"), query2, false).get(); assert payload2.equals(Map.of(gs("member4"), -2.0, gs("member7"), 1.5)); // Returns members with with scores within the range of negative infinity to 3, with their scores.
-
zrangeWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zrangeWithScores(java.lang.String key, RangeOptions.ScoredRangeQuery rangeQuery)Returns the specified range of elements with their scores in the sorted set stored atkey. Similar tozrange(java.lang.String, glide.api.models.commands.RangeOptions.RangeQuery, boolean)but with aWITHSCOREflag.- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- A
Mapof elements and their scores within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
RangeByScore query1 = new RangeByScore(new ScoreBoundary(10), new ScoreBoundary(20)); Map<String, Double> payload1 = client.zrangeWithScores("mySortedSet", query1).get(); assert payload1.equals(Map.of("member1", 10.5, "member2", 15.2)); // Returns members with scores between 10 and 20 (inclusive) with their scores. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); Map<String, Double> payload2 = client.zrangeWithScores("mySortedSet", query2).get(); assert payload2.equals(Map.of("member4", -2.0, "member7", 1.5)); // Returns members with with scores within the range of negative infinity to 3, with their scores.
-
zrangeWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zrangeWithScores(GlideString key, RangeOptions.ScoredRangeQuery rangeQuery)
Returns the specified range of elements with their scores in the sorted set stored atkey. Similar tozrange(java.lang.String, glide.api.models.commands.RangeOptions.RangeQuery, boolean)but with aWITHSCOREflag.- Parameters:
key- The key of the sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- A
Mapof elements and their scores within the specified range. Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - See Also:
- valkey.io for more details.
- Example:
RangeByScore query1 = new RangeByScore(new ScoreBoundary(10), new ScoreBoundary(20)); Map<GlideString, Double> payload1 = client.zrangeWithScores(gs("mySortedSet"), query1).get(); assert payload1.equals(Map.of(gs("member1"), 10.5, gs("member2"), 15.2)); // Returns members with scores between 10 and 20 (inclusive) with their scores. RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); Map<GlideString, Double> payload2 = client.zrangeWithScores(gs("mySortedSet"), query2).get(); assert payload2.equals(Map.of(gs("member4"), -2.0, gs("member7"), 1.5)); // Returns members with with scores within the range of negative infinity to 3, with their scores.
-
zrangestore
java.util.concurrent.CompletableFuture<java.lang.Long> zrangestore(java.lang.String destination, java.lang.String source, RangeOptions.RangeQuery rangeQuery, boolean reverse)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination. Ifdestinationdoesn't exist, a new sorted set is created; if it exists, it's overwritten.- Parameters:
destination- The key for the destination sorted set.source- The key of the source sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- Iftrue, reverses the sorted set, with index0as the element with the highest score.- Returns:
- The number of elements in the resulting sorted set.
- See Also:
- valkey.io for more details.
- Example:
RangeByIndex query1 = new RangeByIndex(0, -1); // Query for all members. Long payload1 = client.zrangestore("destinationKey", "mySortedSet", query1, true).get(); assert payload1 == 7L; RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); // Query for members with scores within the range of negative infinity to 3. Long payload2 = client.zrangestore("destinationKey", "mySortedSet", query2, false).get(); assert payload2 == 5L;
-
zrangestore
java.util.concurrent.CompletableFuture<java.lang.Long> zrangestore(GlideString destination, GlideString source, RangeOptions.RangeQuery rangeQuery, boolean reverse)
Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination. Ifdestinationdoesn't exist, a new sorted set is created; if it exists, it's overwritten.- Parameters:
destination- The key for the destination sorted set.source- The key of the source sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
reverse- Iftrue, reverses the sorted set, with index0as the element with the highest score.- Returns:
- The number of elements in the resulting sorted set.
- See Also:
- valkey.io for more details.
- Example:
RangeByIndex query1 = new RangeByIndex(0, -1); // Query for all members. Long payload1 = client.zrangestore(gs("destinationKey"), gs("mySortedSet"), query1, true).get(); assert payload1 == 7L; RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); // Query for members with scores within the range of negative infinity to 3. Long payload2 = client.zrangestore(gs("destinationKey"), gs("mySortedSet"), query2, false).get(); assert payload2 == 5L;
-
zrangestore
java.util.concurrent.CompletableFuture<java.lang.Long> zrangestore(java.lang.String destination, java.lang.String source, RangeOptions.RangeQuery rangeQuery)Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination. Ifdestinationdoesn't exist, a new sorted set is created; if it exists, it's overwritten.- Parameters:
destination- The key for the destination sorted set.source- The key of the source sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- The number of elements in the resulting sorted set.
- See Also:
- valkey.io for more details.
- Example:
RangeByIndex query1 = new RangeByIndex(0, -1); // Query for all members. Long payload1 = client.zrangestore("destinationKey", "mySortedSet", query1).get(); assert payload1 == 7L; RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); // Query for members with scores within the range of negative infinity to 3. Long payload2 = client.zrangestore("destinationKey", "mySortedSet", query2).get(); assert payload2 == 5L;
-
zrangestore
java.util.concurrent.CompletableFuture<java.lang.Long> zrangestore(GlideString destination, GlideString source, RangeOptions.RangeQuery rangeQuery)
Stores a specified range of elements from the sorted set atsource, into a new sorted set atdestination. Ifdestinationdoesn't exist, a new sorted set is created; if it exists, it's overwritten.- Parameters:
destination- The key for the destination sorted set.source- The key of the source sorted set.rangeQuery- The range query object representing the type of range query to perform.
- For range queries by index (rank), use
RangeOptions.RangeByIndex. - For range queries by lexicographical order, use
RangeOptions.RangeByLex. - For range queries by score, use
RangeOptions.RangeByScore.
- For range queries by index (rank), use
- Returns:
- The number of elements in the resulting sorted set.
- See Also:
- valkey.io for more details.
- Example:
RangeByIndex query1 = new RangeByIndex(0, -1); // Query for all members. Long payload1 = client.zrangestore(gs("destinationKey"), gs("mySortedSet"), query1).get(); assert payload1 == 7L; RangeByScore query2 = new RangeByScore(InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(3)); // Query for members with scores within the range of negative infinity to 3. Long payload2 = client.zrangestore(gs("destinationKey"), gs("mySortedSet"), query2).get(); assert payload2 == 5L;
-
zrank
java.util.concurrent.CompletableFuture<java.lang.Long> zrank(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkey, with scores ordered from low to high, starting from0.
To get the rank ofmemberwith its score, seezrankWithScore(java.lang.String, java.lang.String).- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- The rank of
memberin the sorted set.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zrank("mySortedSet", "member2").get(); assert num1 == 3L; // Indicates that "member2" has the second-lowest score in the sorted set "mySortedSet". Long num2 = client.zcard("mySortedSet", "nonExistingMember").get(); assert num2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrank
java.util.concurrent.CompletableFuture<java.lang.Long> zrank(GlideString key, GlideString member)
Returns the rank ofmemberin the sorted set stored atkey, with scores ordered from low to high, starting from0.
To get the rank ofmemberwith its score, seezrankWithScore(java.lang.String, java.lang.String).- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- The rank of
memberin the sorted set.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zrank(gs("mySortedSet"), gs("member2")).get(); assert num1 == 3L; // Indicates that "member2" has the second-lowest score in the sorted set "mySortedSet". Long num2 = client.zcard(gs("mySortedSet"), gs("nonExistingMember")).get(); assert num2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrankWithScore
java.util.concurrent.CompletableFuture<java.lang.Object[]> zrankWithScore(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the lowest to highest, starting from0.- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- An array containing the rank (as
Long) and score (asDouble) ofmemberin the sorted set.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - Since:
- Valkey 7.2.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Object[] result1 = client.zrankWithScore("mySortedSet", "member2").get(); assert ((Long) result1[0]) == 1L && ((Double) result1[1]) == 6.0; // Indicates that "member2" with score 6.0 has the second-lowest score in the sorted set "mySortedSet". Object[] result2 = client.zrankWithScore("mySortedSet", "nonExistingMember").get(); assert result2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrankWithScore
java.util.concurrent.CompletableFuture<java.lang.Object[]> zrankWithScore(GlideString key, GlideString member)
Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the lowest to highest, starting from0.- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- An array containing the rank (as
Long) and score (asDouble) ofmemberin the sorted set.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - Since:
- Valkey 7.2.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Object[] result1 = client.zrankWithScore(gs("mySortedSet"), gs("member2")).get(); assert ((Long) result1[0]) == 1L && ((Double) result1[1]) == 6.0; // Indicates that "member2" with score 6.0 has the second-lowest score in the sorted set "mySortedSet". Object[] result2 = client.zrankWithScore(gs("mySortedSet"), gs("nonExistingMember")).get(); assert result2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrevrank
java.util.concurrent.CompletableFuture<java.lang.Long> zrevrank(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkey, where scores are ordered from the highest to lowest, starting from0.
To get the rank ofmemberwith its score, seezrevrankWithScore(java.lang.String, java.lang.String).- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- The rank of
memberin the sorted set, where ranks are ordered from high to low based on scores.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zrevrank("mySortedSet", "member2").get(); assert num1 == 1L; // Indicates that "member2" has the second-highest score in the sorted set "mySortedSet". Long num2 = client.zrevrank("mySortedSet", "nonExistingMember").get(); assert num2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrevrank
java.util.concurrent.CompletableFuture<java.lang.Long> zrevrank(GlideString key, GlideString member)
Returns the rank ofmemberin the sorted set stored atkey, where scores are ordered from the highest to lowest, starting from0.
To get the rank ofmemberwith its score, seezrevrankWithScore(java.lang.String, java.lang.String).- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- The rank of
memberin the sorted set, where ranks are ordered from high to low based on scores.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zrevrank(gs("mySortedSet"), gs("member2")).get(); assert num1 == 1L; // Indicates that "member2" has the second-highest score in the sorted set "mySortedSet". Long num2 = client.zrevrank(gs("mySortedSet"), gs("nonExistingMember")).get(); assert num2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrevrankWithScore
java.util.concurrent.CompletableFuture<java.lang.Object[]> zrevrankWithScore(java.lang.String key, java.lang.String member)Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the highest to lowest, starting from0.- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- An array containing the rank (as
Long) and score (asDouble) ofmemberin the sorted set, where ranks are ordered from high to low based on scores.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - Since:
- Valkey 7.2.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Object[] result1 = client.zrevrankWithScore("mySortedSet", "member2").get(); assert ((Long) result1[0]) == 1L && ((Double) result1[1]) == 6.0; // Indicates that "member2" with score 6.0 has the second-highest score in the sorted set "mySortedSet". Object[] result2 = client.zrevrankWithScore("mySortedSet", "nonExistingMember").get(); assert result2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zrevrankWithScore
java.util.concurrent.CompletableFuture<java.lang.Object[]> zrevrankWithScore(GlideString key, GlideString member)
Returns the rank ofmemberin the sorted set stored atkeywith its score, where scores are ordered from the highest to lowest, starting from0.- Parameters:
key- The key of the sorted set.member- The member whose rank is to be retrieved.- Returns:
- An array containing the rank (as
Long) and score (asDouble) ofmemberin the sorted set, where ranks are ordered from high to low based on scores.
Ifkeydoesn't exist, or ifmemberis not present in the set,nullwill be returned. - Since:
- Valkey 7.2.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Object[] result1 = client.zrevrankWithScore(gs("mySortedSet"), gs("member2")).get(); assert ((Long) result1[0]) == 1L && ((Double) result1[1]) == 6.0; // Indicates that "member2" with score 6.0 has the second-highest score in the sorted set "mySortedSet". Object[] result2 = client.zrevrankWithScore(gs("mySortedSet"), gs("nonExistingMember")).get(); assert result2 == null; // Indicates that "nonExistingMember" is not present in the sorted set "mySortedSet".
-
zmscore
java.util.concurrent.CompletableFuture<java.lang.Double[]> zmscore(java.lang.String key, java.lang.String[] members)Returns the scores associated with the specifiedmembersin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.members- An array of members in the sorted set.- Returns:
- An
Arrayof scores of themembers.
If amemberdoes not exist, the corresponding value in theArraywill benull. - See Also:
- valkey.io for more details.
- Example:
Double[] payload = client.zmscore(key1, new String[] {"one", "nonExistentMember", "three"}).get(); assert payload.equals(new Double[] {1.0, null, 3.0});
-
zmscore
java.util.concurrent.CompletableFuture<java.lang.Double[]> zmscore(GlideString key, GlideString[] members)
Returns the scores associated with the specifiedmembersin the sorted set stored atkey.- Parameters:
key- The key of the sorted set.members- An array of members in the sorted set.- Returns:
- An
Arrayof scores of themembers.
If amemberdoes not exist, the corresponding value in theArraywill benull. - See Also:
- valkey.io for more details.
- Example:
Double[] payload = client.zmscore(key1, new GlideString[] {gs("one"), gs("nonExistentMember"), gs("three")}).get(); assert payload.equals(new Double[] {1.0, null, 3.0});
-
zdiff
java.util.concurrent.CompletableFuture<java.lang.String[]> zdiff(java.lang.String[] keys)
Returns the difference between the first sorted set and all the successive sorted sets.
To get the elements with their scores, seezdiffWithScores(java.lang.String[]).- Parameters:
keys- The keys of the sorted sets.- Returns:
- An
arrayof elements representing the difference between the sorted sets.
If the firstkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyarray. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
String[] payload = client.zdiff(new String[] {"sortedSet1", "sortedSet2", "sortedSet3"}).get(); assert payload.equals(new String[]{"element1"});
-
zdiff
java.util.concurrent.CompletableFuture<GlideString[]> zdiff(GlideString[] keys)
Returns the difference between the first sorted set and all the successive sorted sets.
To get the elements with their scores, seezdiffWithScores(java.lang.String[]).- Parameters:
keys- The keys of the sorted sets.- Returns:
- An
arrayof elements representing the difference between the sorted sets.
If the firstkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyarray. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
GlideString[] payload = client.zdiff(new GlideString[] {gs("sortedSet1"), gs("sortedSet2"), gs("sortedSet3")}).get(); assert payload.equals(new GlideString[]{gs("element1")});
-
zdiffWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zdiffWithScores(java.lang.String[] keys)
Returns the difference between the first sorted set and all the successive sorted sets.- Parameters:
keys- The keys of the sorted sets.- Returns:
- A
Mapof elements and their scores representing the difference between the sorted sets.
If the firstkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<String, Double> payload = client.zdiffWithScores(new String[] {"sortedSet1", "sortedSet2", "sortedSet3"}).get(); assert payload.equals(Map.of("element1", 1.0));
-
zdiffWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zdiffWithScores(GlideString[] keys)
Returns the difference between the first sorted set and all the successive sorted sets.- Parameters:
keys- The keys of the sorted sets.- Returns:
- A
Mapof elements and their scores representing the difference between the sorted sets.
If the firstkeydoes not exist, it is treated as an empty sorted set, and the command returns an emptyMap. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Double> payload = client.zdiffWithScores(new GlideString[] {gs("sortedSet1"), gs("sortedSet2"), gs("sortedSet3")}).get(); assert payload.equals(Map.of(gs("element1"), 1.0));
-
zdiffstore
java.util.concurrent.CompletableFuture<java.lang.Long> zdiffstore(java.lang.String destination, java.lang.String[] keys)Calculates the difference between the first sorted set and all the successive sorted sets atkeysand stores the difference as a sorted set todestination, overwriting it if it already exists. Non-existent keys are treated as empty sets.- Parameters:
destination- The key for the resulting sorted set.keys- The keys of the sorted sets to compare.- Returns:
- The number of members in the resulting sorted set stored at
destination. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
Long payload = client.zdiffstore("mySortedSet", new String[] {"key1", "key2"}).get(); assert payload > 0; // At least one member differed in "key1" compared to "key2", and this difference was stored in "mySortedSet".
-
zdiffstore
java.util.concurrent.CompletableFuture<java.lang.Long> zdiffstore(GlideString destination, GlideString[] keys)
Calculates the difference between the first sorted set and all the successive sorted sets atkeysand stores the difference as a sorted set todestination, overwriting it if it already exists. Non-existent keys are treated as empty sets.- Parameters:
destination- The key for the resulting sorted set.keys- The keys of the sorted sets to compare.- Returns:
- The number of members in the resulting sorted set stored at
destination. - Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
Long payload = client.zdiffstore(gs("mySortedSet"), new GlideString[] {gs("key1"), gs("key2")}).get(); assert payload > 0; // At least one member differed in "key1" compared to "key2", and this difference was stored in "mySortedSet".
-
zcount
java.util.concurrent.CompletableFuture<java.lang.Long> zcount(java.lang.String key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)Returns the number of members in the sorted set stored atkeywith scores betweenminScoreandmaxScore.- Parameters:
key- The key of the sorted set.minScore- The minimum score to count from. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.maxScore- The maximum score to count up to. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.- Returns:
- The number of members in the specified score range.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfmaxScore < minScore,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zcount("my_sorted_set", new ScoreBoundary(5.0, true), InfScoreBound.POSITIVE_INFINITY).get(); assert num1 == 2L; // Indicates that there are 2 members with scores between 5.0 (inclusive) and +inf in the sorted set "my_sorted_set". Long num2 = client.zcount("my_sorted_set", new ScoreBoundary(5.0, true), new ScoreBoundary(10.0, false)).get(); assert num2 == 1L; // Indicates that there is one member with ScoreBoundary 5.0 <= score < 10.0 in the sorted set "my_sorted_set".
-
zcount
java.util.concurrent.CompletableFuture<java.lang.Long> zcount(GlideString key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)
Returns the number of members in the sorted set stored atkeywith scores betweenminScoreandmaxScore.- Parameters:
key- The key of the sorted set.minScore- The minimum score to count from. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.maxScore- The maximum score to count up to. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.- Returns:
- The number of members in the specified score range.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfmaxScore < minScore,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zcount(gs("my_sorted_set"), new ScoreBoundary(5.0, true), InfScoreBound.POSITIVE_INFINITY).get(); assert num1 == 2L; // Indicates that there are 2 members with scores between 5.0 (inclusive) and +inf in the sorted set "my_sorted_set". Long num2 = client.zcount(gs("my_sorted_set"), new ScoreBoundary(5.0, true), new ScoreBoundary(10.0, false)).get(); assert num2 == 1L; // Indicates that there is one member with ScoreBoundary 5.0 <= score < 10.0 in the sorted set "my_sorted_set".
-
zremrangebyrank
java.util.concurrent.CompletableFuture<java.lang.Long> zremrangebyrank(java.lang.String key, long start, long end)Removes all elements in the sorted set stored atkeywith rank betweenstartandend. Bothstartandendare zero-based indexes with0being the element with the lowest score. These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score.- Parameters:
key- The key of the sorted set.start- The starting point of the range.end- The end of the range.- Returns:
- The number of elements removed.
Ifstartexceeds the end of the sorted set, or ifstartis greater thanend,0returned.
Ifendexceeds the actual end of the sorted set, the range will stop at the actual end of the sorted set.
Ifkeydoes not exist0will be returned. - See Also:
- valkey.io for more details.
- Example:
Long payload1 = client.zremrangebyrank("mySortedSet", 0, 4).get(); assert payload1 == 5L; // Indicates that 5 elements, with ranks ranging from 0 to 4 (inclusive), have been removed from "mySortedSet". Long payload2 = client.zremrangebyrank("mySortedSet", 0, 4).get(); assert payload2 == 0L; // Indicates that nothing was removed.
-
zremrangebyrank
java.util.concurrent.CompletableFuture<java.lang.Long> zremrangebyrank(GlideString key, long start, long end)
Removes all elements in the sorted set stored atkeywith rank betweenstartandend. Bothstartandendare zero-based indexes with0being the element with the lowest score. These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score.- Parameters:
key- The key of the sorted set.start- The starting point of the range.end- The end of the range.- Returns:
- The number of elements removed.
Ifstartexceeds the end of the sorted set, or ifstartis greater thanend,0returned.
Ifendexceeds the actual end of the sorted set, the range will stop at the actual end of the sorted set.
Ifkeydoes not exist0will be returned. - See Also:
- valkey.io for more details.
- Example:
Long payload1 = client.zremrangebyrank(gs("mySortedSet"), 0, 4).get(); assert payload1 == 5L; // Indicates that 5 elements, with ranks ranging from 0 to 4 (inclusive), have been removed from "mySortedSet". Long payload2 = client.zremrangebyrank(gs("mySortedSet"), 0, 4).get(); assert payload2 == 0L; // Indicates that nothing was removed.
-
zremrangebylex
java.util.concurrent.CompletableFuture<java.lang.Long> zremrangebylex(java.lang.String key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)Removes all elements in the sorted set stored atkeywith a lexicographical order betweenminLexandmaxLex.- Parameters:
key- The key of the sorted set.minLex- The minimum bound of the lexicographical range. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.maxLex- The maximum bound of the lexicographical range. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.- Returns:
- The number of members removed from the sorted set.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfminLexis greater thanmaxLex,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long payload1 = client.zremrangebylex("mySortedSet", new LexBoundary("a", false), new LexBoundary("e")).get(); assert payload1 == 4L; // Indicates that 4 members, with lexicographical values ranging from "a" (exclusive) to "e" (inclusive), have been removed from "mySortedSet". Long payload2 = client.zremrangebylex("mySortedSet", InfLexBound.NEGATIVE_INFINITY , new LexBoundary("e")).get(); assert payload2 == 0L; // Indicates that no elements were removed.
-
zremrangebylex
java.util.concurrent.CompletableFuture<java.lang.Long> zremrangebylex(GlideString key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)
Removes all elements in the sorted set stored atkeywith a lexicographical order betweenminLexandmaxLex.- Parameters:
key- The key of the sorted set.minLex- The minimum bound of the lexicographical range. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.maxLex- The maximum bound of the lexicographical range. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.- Returns:
- The number of members removed from the sorted set.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfminLexis greater thanmaxLex,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long payload1 = client.zremrangebylex(gs("mySortedSet"), new LexBoundary("a", false), new LexBoundary("e")).get(); assert payload1 == 4L; // Indicates that 4 members, with lexicographical values ranging from "a" (exclusive) to "e" (inclusive), have been removed from "mySortedSet". Long payload2 = client.zremrangebylex(gs("mySortedSet"), InfLexBound.NEGATIVE_INFINITY, new LexBoundary("e")).get(); assert payload2 == 0L; // Indicates that no elements were removed.
-
zremrangebyscore
java.util.concurrent.CompletableFuture<java.lang.Long> zremrangebyscore(java.lang.String key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)Removes all elements in the sorted set stored atkeywith a score betweenminScoreandmaxScore.- Parameters:
key- The key of the sorted set.minScore- The minimum score to remove from. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.maxScore- The maximum score to remove to. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.- Returns:
- The number of members removed.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfminScoreis greater thanmaxScore,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long payload1 = client.zremrangebyscore("mySortedSet", new ScoreBoundary(1, false), new ScoreBoundary(5)).get(); assert payload1 == 4L; // Indicates that 4 members, with scores ranging from 1 (exclusive) to 5 (inclusive), have been removed from "mySortedSet". Long payload2 = client.zremrangebyscore("mySortedSet", InfScoreBound.NEGATIVE_INFINITY , new ScoreBoundary(-42)).get(); assert payload2 == 0L; // Indicates that no elements were removed.
-
zremrangebyscore
java.util.concurrent.CompletableFuture<java.lang.Long> zremrangebyscore(GlideString key, RangeOptions.ScoreRange minScore, RangeOptions.ScoreRange maxScore)
Removes all elements in the sorted set stored atkeywith a score betweenminScoreandmaxScore.- Parameters:
key- The key of the sorted set.minScore- The minimum score to remove from. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.maxScore- The maximum score to remove to. Can be an implementation ofRangeOptions.InfScoreBoundrepresenting positive/negative infinity, orRangeOptions.ScoreBoundaryrepresenting a specific score and inclusivity.- Returns:
- The number of members removed.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfminScoreis greater thanmaxScore,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long payload1 = client.zremrangebyscore(gs("mySortedSet"), new ScoreBoundary(1, false), new ScoreBoundary(5)).get(); assert payload1 == 4L; // Indicates that 4 members, with scores ranging from 1 (exclusive) to 5 (inclusive), have been removed from "mySortedSet". Long payload2 = client.zremrangebyscore(gs("mySortedSet"), InfScoreBound.NEGATIVE_INFINITY, new ScoreBoundary(-42)).get(); assert payload2 == 0L; // Indicates that no elements were removed.
-
zlexcount
java.util.concurrent.CompletableFuture<java.lang.Long> zlexcount(java.lang.String key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)Returns the number of members in the sorted set stored atkeywith scores betweenminLexandmaxLex.- Parameters:
key- The key of the sorted set.minLex- The minimum lex to count from. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.maxLex- The maximum lex to count up to. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.- Returns:
- The number of members in the specified lex range.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfmaxLex < minLex,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zlexcount("my_sorted_set", new LexBoundary("c", true), InfLexBound.POSITIVE_INFINITY).get(); assert num1 == 2L; // Indicates that there are 2 members with lex scores between "c" (inclusive) and positive infinity in the sorted set "my_sorted_set". Long num2 = client.zlexcount("my_sorted_set", new ScoreBoundary("c", true), new ScoreBoundary("k", false)).get(); assert num2 == 1L; // Indicates that there is one member with LexBoundary "c" <= score < "k" in the sorted set "my_sorted_set".
-
zlexcount
java.util.concurrent.CompletableFuture<java.lang.Long> zlexcount(GlideString key, RangeOptions.LexRange minLex, RangeOptions.LexRange maxLex)
Returns the number of members in the sorted set stored atkeywith scores betweenminLexandmaxLex.- Parameters:
key- The key of the sorted set.minLex- The minimum lex to count from. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.maxLex- The maximum lex to count up to. Can be an implementation ofRangeOptions.InfLexBoundrepresenting positive/negative infinity, orRangeOptions.LexBoundaryrepresenting a specific lex and inclusivity.- Returns:
- The number of members in the specified lex range.
Ifkeydoes not exist, it is treated as an empty sorted set, and the command returns0.
IfmaxLex < minLex,0is returned. - See Also:
- valkey.io for more details.
- Example:
Long num1 = client.zlexcount(gs("my_sorted_set"), new LexBoundary(gs("c"), true), InfLexBound.POSITIVE_INFINITY).get(); assert num1 == 2L; // Indicates that there are 2 members with lex scores between "c" (inclusive) and positive infinity in the sorted set "my_sorted_set". Long num2 = client.zlexcount(gs("my_sorted_set"), new ScoreBoundary(gs("c"), true), new ScoreBoundary(gs("k"), false)).get(); assert num2 == 1L; // Indicates that there is one member with LexBoundary "c" <= score < "k" in the sorted set "my_sorted_set".
-
zunionstore
java.util.concurrent.CompletableFuture<java.lang.Long> zunionstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
WeightedKeys weightedKeys = new WeightedKeys(Arrays.asList(Pair.of("mySortedSet1", 1.0), Pair.of("mySortedSet2", 2.0))); Long payload = client.zunionstore("newSortedSet", weightedKeys, Aggregate.MAX).get() assert payload == 3L; // Indicates the new sorted set contains three members from the union of "mySortedSet1" and "mySortedSet2".
-
zunionstore
java.util.concurrent.CompletableFuture<java.lang.Long> zunionstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)
Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
WeightedKeysBinary weightedKeys = new WeightedKeys(Arrays.asList(Pair.of(gs("mySortedSet1"), 1.0), Pair.of(gs("mySortedSet2"), 2.0))); Long payload = client.zunionstore(gs("newSortedSet"), weightedKeys, Aggregate.MAX).get() assert payload == 3L; // Indicates the new sorted set contains three members from the union of gs("mySortedSet1") and gs("mySortedSet2").
-
zunionstore
java.util.concurrent.CompletableFuture<java.lang.Long> zunionstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); Long payload = client.zunionstore("newSortedSet", keyArray).get() assert payload == 3L; // Indicates the new sorted set contains three members from the union of "mySortedSet1" and "mySortedSet2".
-
zunionstore
java.util.concurrent.CompletableFuture<java.lang.Long> zunionstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Computes the union of sorted sets given by the specifiedKeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); Long payload = client.zunionstore(gs("newSortedSet"), keyArray).get() assert payload == 3L; // Indicates the new sorted set contains three members from the union of gs("mySortedSet1") and gs("mySortedSet2").
-
zinterstore
java.util.concurrent.CompletableFuture<java.lang.Long> zinterstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
WeightedKeys weightedKeys = new WeightedKeys(Arrays.asList(Pair.of("mySortedSet1", 1.0), Pair.of("mySortedSet2", 2.0))); Long payload = client.zinterstore("newSortedSet", weightedKeys, Aggregate.MAX).get() assert payload == 3L; // Indicates the new sorted set contains three members from the intersection of "mySortedSet1" and "mySortedSet2".
-
zinterstore
java.util.concurrent.CompletableFuture<java.lang.Long> zinterstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)
Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
WeightedKeysBinary weightedKeys = new WeightedKeysBinary(Arrays.asList(Pair.of(gs("mySortedSet1"), 1.0), Pair.of(gs("mySortedSet2"), 2.0))); Long payload = client.zinterstore(gs("newSortedSet"), weightedKeys, Aggregate.MAX).get() assert payload == 3L; // Indicates the new sorted set contains three members from the intersection of "mySortedSet1" and "mySortedSet2".
-
zinterstore
java.util.concurrent.CompletableFuture<java.lang.Long> zinterstore(java.lang.String destination, WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); Long payload = client.zinterstore("newSortedSet", keyArray).get() assert payload == 3L; // Indicates the new sorted set contains three members from the intersection of "mySortedSet1" and "mySortedSet2".
-
zinterstore
java.util.concurrent.CompletableFuture<java.lang.Long> zinterstore(GlideString destination, WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Computes the intersection of sorted sets given by the specifiedkeysOrWeightedKeys, and stores the result indestination. Ifdestinationalready exists, it is overwritten. Otherwise, a new sorted set will be created.- Parameters:
destination- The key of the destination sorted set.keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The number of elements in the resulting sorted set stored at
destination. - See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArray(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); Long payload = client.zinterstore(gs("newSortedSet"), keyArray).get() assert payload == 3L; // Indicates the new sorted set contains three members from the intersection of "mySortedSet1" and "mySortedSet2".
-
zmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> zmpop(java.lang.String[] keys, ScoreFilter modifier)Pops a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop the member with the lowest/highest score accordingly.- Returns:
- A
mapcontaining the key name of the set from which the element was popped, and a member-scoreMapof the popped element.
If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<String, Object> result = client.zmpop(new String[] { "zSet1", "zSet2" }, MAX).get(); Map<String, Double> data = (Map<String, Double>)result.values().toArray()[0]; String element = data.keySet().toArray(String[]::new)[0]; System.out.printf("Popped '%s' with score %d from '%s'%n", element, data.get(element), result[0]);
-
zmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>> zmpop(GlideString[] keys, ScoreFilter modifier)
Pops a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop the member with the lowest/highest score accordingly.- Returns:
- A
mapcontaining the key name of the set from which the element was popped, and a member-scoreMapof the popped element.
If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Object> result = client.zmpop(new GlideString[] { gs("zSet1"), gs("zSet2") }, MAX).get(); Map<GlideString, Double> data = (Map<GlideString, Double>)result.values().toArray()[0]; GlideString element = data.keySet().toArray(GlideString[]::new)[0]; System.out.printf("Popped '%s' with score %d from '%s'%n", element, data.get(element), result[0]);
-
zmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> zmpop(java.lang.String[] keys, ScoreFilter modifier, long count)Pops multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.count- The number of elements to pop.- Returns:
- A
mapcontaining the key name of the set from which elements were popped, and a member-scoreMapof the popped elements.
If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<String, Object> result = client.zmpop(new String[] { "zSet1", "zSet2" }, MAX, 2).get(); Map<String, Double> data = (Map<String, Double>)result.values().toArray()[0]; for (Map.Entry<String, Double> entry : data.entrySet()) { System.out.printf("Popped '%s' with score %d from '%s'%n", entry.getKey(), entry.getValue(), result[0]); }
-
zmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>> zmpop(GlideString[] keys, ScoreFilter modifier, long count)
Pops multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.count- The number of elements to pop.- Returns:
- A
mapcontaining the key name of the set from which elements were popped, and a member-scoreMapof the popped elements.
If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Object> result = client.zmpop(new GlideString[] { gs("zSet1"), gs("zSet2") }, MAX, 2).get(); Map<GlideString, Double> data = (Map<GlideString, Double>)result.values().toArray()[0]; for (Map.Entry<GlideString, Double> entry : data.entrySet()) { System.out.printf("Popped '%s' with score %d from '%s'%n", entry.getKey(), entry.getValue(), result[0]); }
-
bzmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> bzmpop(java.lang.String[] keys, ScoreFilter modifier, double timeout)Blocks the connection until it pops and returns a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter).- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A
Mapcontaining the key name of the set from which an element was popped, and a member-scoreMapof the popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<String, Object> result = client.bzmpop(new String[] { "zSet1", "zSet2" }, MAX, 0.1).get(); Map<String, Double> data = (Map<String, Double>)result.values().toArray()[0]; String element = data.keySet().toArray(String[]::new)[0]; System.out.printf("Popped '%s' with score %d from '%s'%n", element, data.get(element), result[0]);
-
bzmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>> bzmpop(GlideString[] keys, ScoreFilter modifier, double timeout)
Blocks the connection until it pops and returns a member-score pair from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter).- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A
mapcontaining the key name of the set from which an element was popped, and a member-scoreMapof the popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Object> result = client.bzmpop(new GlideString[] { gs("zSet1"), gs("zSet2") }, MAX, 0.1).get(); Map<GlideString, Double> data = (Map<GlideString, Double>)result.values().toArray()[0]; GlideString element = data.keySet().toArray(GlideString[]::new)[0]; System.out.printf("Popped '%s' with score %d from '%s'%n", element, data.get(element), result[0]);
-
bzmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> bzmpop(java.lang.String[] keys, ScoreFilter modifier, double timeout, long count)Blocks the connection until it pops and returns multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter, long).- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.count- The number of elements to pop.- Returns:
- A
mapcontaining the key name of the set from which elements were popped, and a member-scoreMapof the popped elements.
If no members could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<String, Object> result = client.bzmpop(new String[] { "zSet1", "zSet2" }, MAX, 0.1, 2).get(); Map<String, Double> data = (Map<String, Double>)result.values().toArray()[0]; for (Map.Entry<String, Double> entry : data.entrySet()) { System.out.printf("Popped '%s' with score %d from '%s'%n", entry.getKey(), entry.getValue(), result[0]); }
-
bzmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>> bzmpop(GlideString[] keys, ScoreFilter modifier, double timeout, long count)
Blocks the connection until it pops and returns multiple member-score pairs from the first non-empty sorted set, with the givenkeysbeing checked in the order they are provided.
BZMPOPis the blocking variant ofzmpop(String[], ScoreFilter, long).- Parameters:
keys- The keys of the sorted sets.modifier- The element pop criteria - eitherScoreFilter.MINorScoreFilter.MAXto pop members with the lowest/highest scores accordingly.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.count- The number of elements to pop.- Returns:
- A
mapcontaining the key name of the set from which elements were popped, and a member-scoreMapof the popped elements.
If no members could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Map<GlideString, Object> result = client.bzmpop(new GlideString[] { gs("zSet1"), gs("zSet2") }, MAX, 0.1, 2).get(); Map<GlideString, Double> data = (Map<GlideString, Double>)result.values().toArray()[0]; for (Map.Entry<GlideString, Double> entry : data.entrySet()) { System.out.printf("Popped '%s' with score %d from '%s'%n", entry.getKey(), entry.getValue(), result[0]); }
-
zunion
java.util.concurrent.CompletableFuture<java.lang.String[]> zunion(WeightAggregateOptions.KeyArray keys)
Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).- Parameters:
keys- The keys of the sorted sets.- Returns:
- The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); String[] payload1 = client.zunion(keyArray).get() assert Arrays.equals(payload1, new String[] {"elem1", "elem2", "elem3"}); WeightedKeys weightedKeys = new WeightedKeys(Arrays.asList(Pair.of("mySortedSet1", 2.0), Pair.of("mySortedSet2", 2.0))); String[] payload2 = client.zunion(weightedKeys).get() assert Arrays.equals(payload2, new String[] {"elem1", "elem2", "elem3"});
-
zunion
java.util.concurrent.CompletableFuture<GlideString[]> zunion(WeightAggregateOptions.KeyArrayBinary keys)
Returns the union of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezunionWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys, glide.api.models.commands.WeightAggregateOptions.Aggregate).- Parameters:
keys- The keys of the sorted sets.- Returns:
- The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); GlideString[] payload1 = client.zunion(keyArray).get() assert Arrays.equals(payload1, new GlideString[] {gs("elem1"), gs("elem2"), gs("elem3")}); WeightedKeysBinary weightedKeys = new WeightedKeysBinary(Arrays.asList(Pair.of(gs("mySortedSet1"), 2.0), Pair.of(gs("mySortedSet2"), 2.0))); GlideString[] payload2 = client.zunion(weightedKeys).get() assert Arrays.equals(payload2, new GlideString[] {gs("elem1"), gs("elem2"), gs("elem3")});
-
zunionWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); Map<String, Double> payload1 = client.zunionWithScores(keyArray, Aggregate.MAX).get(); assert Arrays.equals(payload1, Map.of("elem1", 1.0, "elem2", 2.0, "elem3", 3.0)); WeightedKeys weightedKeys = new WeightedKeys(Arrays.asList(Pair.of("mySortedSet1", 2.0), Pair.of("mySortedSet2", 2.0))); Map<String, Double> payload2 = client.zunionWithScores(keyArray, Aggregate.SUM).get(); assert Arrays.equals(payload2, Map.of("elem1", 2.0, "elem2", 4.0, "elem3", 6.0));
-
zunionWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); Map<GlideString, Double> payload1 = client.zunionWithScores(keyArray, Aggregate.MAX).get(); assert Arrays.equals(payload1, Map.of(gs("elem1"), 1.0, gs("elem2"), 2.0, gs("elem3"), 3.0)); WeightedKeysBinary weightedKeys = new WeightedKeysBinary(Arrays.asList(Pair.of(gs("mySortedSet1"), 2.0), Pair.of(gs("mySortedSet2"), 2.0))); Map<GlideString, Double> payload2 = client.zunionWithScores(weightedKeys, Aggregate.SUM).get(); assert Arrays.equals(payload2, Map.of(gs("elem1"), 2.0, gs("elem2"), 4.0, gs("elem3"), 6.0));
-
zunionWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); Map<String, Double> payload1 = client.zunionWithScores(keyArray).get(); assert Arrays.equals(payload1, Map.of("elem1", 1.0, "elem2", 2.0, "elem3", 3.0)); WeightedKeys weightedKeys = new WeightedKeys(Arrays.asList(Pair.of("mySortedSet1", 2.0), Pair.of("mySortedSet2", 2.0))); Map<String, Double> payload2 = client.zunionWithScores(keyArray).get(); assert Arrays.equals(payload2, Map.of("elem1", 2.0, "elem2", 4.0, "elem3", 6.0));
-
zunionWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zunionWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Returns the union of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.
To perform azunionoperation while specifying aggregation settings, usezunionWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The resulting sorted set from the union.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); Map<GlideString, Double> payload1 = client.zunionWithScores(keyArray).get(); assert Arrays.equals(payload1, Map.of(gs("elem1"), 1.0, gs("elem2"), 2.0, gs("elem3"), 3.0)); WeightedKeysBinary weightedKeys = new WeightedKeysBinary(Arrays.asList(Pair.of(gs("mySortedSet1"), 2.0), Pair.of(gs("mySortedSet2"), 2.0))); Map<GlideString, Double> payload2 = client.zunionWithScores(keyArray).get(); assert Arrays.equals(payload2, Map.of(gs("elem1"), 2.0, gs("elem2"), 4.0, gs("elem3"), 6.0));
-
zinter
java.util.concurrent.CompletableFuture<java.lang.String[]> zinter(WeightAggregateOptions.KeyArray keys)
Returns the intersection of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezinterWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys).- Parameters:
keys- The keys of the sorted sets.- Returns:
- The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); String[] payload = client.zinter(keyArray).get() assert payload.equals(new String[] {"elem1", "elem2", "elem3"});
-
zinter
java.util.concurrent.CompletableFuture<GlideString[]> zinter(WeightAggregateOptions.KeyArrayBinary keys)
Returns the intersection of members from sorted sets specified by the givenkeys.
To get the elements with their scores, seezinterWithScores(glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys).- Parameters:
keys- The keys of the sorted sets.- Returns:
- The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); GlideString[] payload = client.zinter(keyArray).get() assert payload.equals(new GlideString[] {gs("elem1"), gs("elem2"), gs("elem3")});
-
zinterWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys. To perform azinteroperation while specifying aggregation settings, usezinterWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); Map<String, Double> payload1 = client.zinterWithScores(keyArray).get(); assert payload1.equals(Map.of("elem1", 1.0, "elem2", 2.0, "elem3", 3.0));
-
zinterWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys. To perform azinteroperation while specifying aggregation settings, usezinterWithScores(KeysOrWeightedKeys, Aggregate).- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
- Returns:
- The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); Map<GlideString, Double> payload1 = client.zinterWithScores(keyArray).get(); assert payload1.equals(Map.of(gs("elem1"), 1.0, gs("elem2"), 2.0, gs("elem3"), 3.0));
-
zinterWithScores
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Double>> zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeys keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayfor keys only. - Use
WeightAggregateOptions.WeightedKeysfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArray keyArray = new KeyArray(new String[] {"mySortedSet1", "mySortedSet2"}); Map<String, Double> payload1 = client.zinterWithScores(keyArray, Aggregate.MAX).get(); assert payload1.equals(Map.of("elem1", 1.0, "elem2", 2.0, "elem3", 3.0));
-
zinterWithScores
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Double>> zinterWithScores(WeightAggregateOptions.KeysOrWeightedKeysBinary keysOrWeightedKeys, WeightAggregateOptions.Aggregate aggregate)
Returns the intersection of members and their scores from sorted sets specified by the givenkeysOrWeightedKeys.- Parameters:
keysOrWeightedKeys- The keys of the sorted sets with possible formats:- Use
WeightAggregateOptions.KeyArrayBinaryfor keys only. - Use
WeightedKeysBinaryfor weighted keys with score multipliers.
- Use
aggregate- Specifies the aggregation strategy to apply when combining the scores of elements.- Returns:
- The resulting sorted set from the intersection.
- Since:
- Valkey 6.2 and above.
- See Also:
- valkey.io for more details.
- Example:
KeyArrayBinary keyArray = new KeyArrayBinary(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}); Map<GlideString, Double> payload1 = client.zinterWithScores(keyArray, AggregateBinary.MAX).get(); assert payload1.equals(Map.of(gs("elem1"), 1.0, gs("elem2"), 2.0, gs("elem3"), 3.0));
-
zrandmember
java.util.concurrent.CompletableFuture<java.lang.String> zrandmember(java.lang.String key)
Returns a random element from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.- Returns:
- A
Stringrepresenting a random element from the sorted set.
If the sorted set does not exist or is empty, the response will benull. - See Also:
- valkey.io for more details.
- Example:
String payload1 = client.zrandmember("mySortedSet").get(); assert payload1.equals("GLIDE"); String payload2 = client.zrandmember("nonExistingSortedSet").get(); assert payload2 == null;
-
zrandmember
java.util.concurrent.CompletableFuture<GlideString> zrandmember(GlideString key)
Returns a random element from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.- Returns:
- A
Stringrepresenting a random element from the sorted set.
If the sorted set does not exist or is empty, the response will benull. - See Also:
- valkey.io for more details.
- Example:
GlideString payload1 = client.zrandmember(gs("mySortedSet")).get(); assert payload1.equals(gs("GLIDE")); GlideString payload2 = client.zrandmember(gs("nonExistingSortedSet")).get(); assert payload2 == null;
-
zrandmemberWithCount
java.util.concurrent.CompletableFuture<java.lang.String[]> zrandmemberWithCount(java.lang.String key, long count)Returns a random element from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows for duplicates.- Returns:
- An
arrayof elements from the sorted set.
If the sorted set does not exist or is empty, the response will be an emptyarray. - See Also:
- valkey.io for more details.
- Example:
String[] payload1 = client.zrandmember("mySortedSet", -3).get(); assert payload1.equals(new String[] {"GLIDE", "GLIDE", "JAVA"}); String[] payload2 = client.zrandmember("nonExistingSortedSet", 3).get(); assert payload2.length == 0;
-
zrandmemberWithCount
java.util.concurrent.CompletableFuture<GlideString[]> zrandmemberWithCount(GlideString key, long count)
Retrieves random elements from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows for duplicates.- Returns:
- An
arrayof elements from the sorted set.
If the sorted set does not exist or is empty, the response will be an emptyarray. - See Also:
- valkey.io for more details.
- Example:
GlideString[] payload1 = client.zrandmemberWithCount(gs("mySortedSet"), -3).get(); assert payload1.equals(new GlideString[] {gs("GLIDE"), gs("GLIDE"), gs("JAVA")}); GlideString[] payload2 = client.zrandmemberWithCount(gs("nonExistingSortedSet"), 3).get(); assert payload2.length == 0;
-
zrandmemberWithCountWithScores
java.util.concurrent.CompletableFuture<java.lang.Object[][]> zrandmemberWithCountWithScores(java.lang.String key, long count)Retrieves random elements along with their scores from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows duplicates.- Returns:
- An
arrayof[element, score]arrays, where element is aStringand score is aDouble.
If the sorted set does not exist or is empty, the response will be an emptyarray. - See Also:
- valkey.io for more details.
- Example:
Object[][] data = client.zrandmemberWithCountWithScores("mySortedSet", -3).get(); assert data.length == 3; for (Object[] memberScorePair : data) { System.out.printf("Member: '%s', score: %d", memberScorePair[0], memberScorePair[1]); }
-
zrandmemberWithCountWithScores
java.util.concurrent.CompletableFuture<java.lang.Object[][]> zrandmemberWithCountWithScores(GlideString key, long count)
Retrieves random elements along with their scores from the sorted set stored atkey.- Parameters:
key- The key of the sorted set.count- The number of elements to return.
Ifcountis positive, returns unique elements.
If negative, allows duplicates.- Returns:
- An
arrayof[element, score]arrays, where element is aStringand score is aDouble.
If the sorted set does not exist or is empty, the response will be an emptyarray. - See Also:
- valkey.io for more details.
- Example:
Object[][] data = client.zrandmemberWithCountWithScores(gs("mySortedSet"), -3).get(); assert data.length == 3; for (Object[] memberScorePair : data) { System.out.printf("Member: '%s', score: %d", memberScorePair[0], memberScorePair[1]); }
-
zincrby
java.util.concurrent.CompletableFuture<java.lang.Double> zincrby(java.lang.String key, double increment, java.lang.String member)Increments the score ofmemberin the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score. Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.- Parameters:
key- The key of the sorted set.increment- The score increment.member- A member of the sorted set.- Returns:
- The new score of
member. - See Also:
- valkey.io for more details.
- Example:
Double score = client.zincrby("mySortedSet", -3.14, "value").get(); assert score > 0; // member "value" existed in the set before score was altered
-
zincrby
java.util.concurrent.CompletableFuture<java.lang.Double> zincrby(GlideString key, double increment, GlideString member)
Increments the score ofmemberin the sorted set stored atkeybyincrement.
Ifmemberdoes not exist in the sorted set, it is added withincrementas its score. Ifkeydoes not exist, a new sorted set with the specified member as its sole member is created.- Parameters:
key- The key of the sorted set.increment- The score increment.member- A member of the sorted set.- Returns:
- The new score of
member. - See Also:
- valkey.io for more details.
- Example:
Double score = client.zincrby(gs("mySortedSet"), -3.14, gs("value")).get(); assert score > 0; // member "value" existed in the set before score was altered
-
zintercard
java.util.concurrent.CompletableFuture<java.lang.Long> zintercard(java.lang.String[] keys)
Returns the cardinality of the intersection of the sorted sets specified bykeys.- Parameters:
keys- The keys of the sorted sets to intersect.- Returns:
- The cardinality of the intersection of the given sorted sets.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Long length = client.zintercard(new String[] {"mySortedSet1", "mySortedSet2"}).get(); assert length == 3L;
-
zintercard
java.util.concurrent.CompletableFuture<java.lang.Long> zintercard(GlideString[] keys)
Returns the cardinality of the intersection of the sorted sets specified bykeys.- Parameters:
keys- The keys of the sorted sets to intersect.- Returns:
- The cardinality of the intersection of the given sorted sets.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Long length = client.zintercard(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}).get(); assert length == 3L;
-
zintercard
java.util.concurrent.CompletableFuture<java.lang.Long> zintercard(java.lang.String[] keys, long limit)Returns the cardinality of the intersection of the sorted sets specified bykeys. If the intersection cardinality reacheslimitpartway through the computation, the algorithm will exit early and yieldlimitas the cardinality.- Parameters:
keys- The keys of the sorted sets to intersect.limit- Specifies a maximum number for the intersection cardinality. If limit is set to0the range will be unlimited.- Returns:
- The cardinality of the intersection of the given sorted sets, or the
limitif reached. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Long length = client.zintercard(new String[] {"mySortedSet1", "mySortedSet2"}, 5).get(); assert length == 3L;
-
zintercard
java.util.concurrent.CompletableFuture<java.lang.Long> zintercard(GlideString[] keys, long limit)
Returns the cardinality of the intersection of the sorted sets specified bykeys. If the intersection cardinality reacheslimitpartway through the computation, the algorithm will exit early and yieldlimitas the cardinality.- Parameters:
keys- The keys of the sorted sets to intersect.limit- Specifies a maximum number for the intersection cardinality. If limit is set to0the range will be unlimited.- Returns:
- The cardinality of the intersection of the given sorted sets, or the
limitif reached. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for more details.
- Example:
Long length = client.zintercard(new GlideString[] {gs("mySortedSet1"), gs("mySortedSet2")}, 5).get(); assert length == 3L;
-
zscan
java.util.concurrent.CompletableFuture<java.lang.Object[]> zscan(java.lang.String key, java.lang.String cursor)Iterates incrementally over a sorted set.- Parameters:
key- The key of the sorted set.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the sorted set. The second element is always anArrayof the subset of the sorted set held inkey. The array in the second element is always a flattened series ofStringpairs, where the value is at even indices and the score is at odd indices. - See Also:
- valkey.io for details.
- Example:
// Assume key contains a set with 200 member-score pairs String cursor = "0"; Object[] result; do { result = client.zscan(key1, cursor).get(); cursor = result[0].toString(); Object[] stringResults = (Object[]) result[1]; System.out.println("\nZSCAN iteration:"); for (int i = 0; i < stringResults.length; i += 2) { System.out.printf("{%s=%s}", stringResults[i], stringResults[i + 1]); if (i + 2 < stringResults.length) { System.out.print(", "); } } } while (!cursor.equals("0"));
-
zscan
java.util.concurrent.CompletableFuture<java.lang.Object[]> zscan(GlideString key, GlideString cursor)
Iterates incrementally over a sorted set.- Parameters:
key- The key of the sorted set.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the sorted set. The second element is always anArrayof the subset of the sorted set held inkey. The array in the second element is always a flattened series ofStringpairs, where the value is at even indices and the score is at odd indices. - See Also:
- valkey.io for details.
- Example:
// Assume key contains a set with 200 member-score pairs GlideString cursor = gs("0"); Object[] result; do { result = client.zscan(key1, cursor).get(); cursor = gs(result[0].toString()); Object[] glideStringResults = (Object[]) result[1]; System.out.println("\nZSCAN iteration:"); for (int i = 0; i < glideStringResults.length; i += 2) { System.out.printf("{%s=%s}", glideStringResults[i], glideStringResults[i + 1]); if (i + 2 < glideStringResults.length) { System.out.print(", "); } } } while (!cursor.equals(gs("0")));
-
zscan
java.util.concurrent.CompletableFuture<java.lang.Object[]> zscan(java.lang.String key, java.lang.String cursor, ZScanOptions zScanOptions)Iterates incrementally over a sorted set.- Parameters:
key- The key of the sorted set.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.zScanOptions- TheZScanOptions.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the sorted set. The second element is always anArrayof the subset of the sorted set held inkey. The array in the second element is a flattened series ofStringpairs, where the value is at even indices and the score is at odd indices. IfZScanOptions.ZScanOptionsBuilder.noScores(boolean)is totrue, the second element will only contain the members without scores. - See Also:
- valkey.io for details.
- Example:
// Assume key contains a set with 200 member-score pairs String cursor = "0"; Object[] result; do { result = client.zscan(key1, cursor, ZScanOptions.builder().matchPattern("*").count(20L).build()).get(); cursor = result[0].toString(); Object[] stringResults = (Object[]) result[1]; System.out.println("\nZSCAN iteration:"); for (int i = 0; i < stringResults.length; i += 2) { System.out.printf("{%s=%s}", stringResults[i], stringResults[i + 1]); if (i + 2 < stringResults.length) { System.out.print(", "); } } } while (!cursor.equals("0"));
-
zscan
java.util.concurrent.CompletableFuture<java.lang.Object[]> zscan(GlideString key, GlideString cursor, ZScanOptionsBinary zScanOptions)
Iterates incrementally over a sorted set.- Parameters:
key- The key of the sorted set.cursor- The cursor that points to the next iteration of results. A value of"0"indicates the start of the search.zScanOptions- TheZScanOptions.- Returns:
- An
ArrayofObjects. The first element is always thecursorfor the next iteration of results."0"will be thecursorreturned on the last iteration of the sorted set. The second element is always anArrayof the subset of the sorted set held inkey. The array in the second element is a flattened series ofStringpairs, where the value is at even indices and the score is at odd indices. IfZScanOptionsBinary.ZScanOptionsBinaryBuilder.noScores(boolean)is totrue, the second element will only contain the members without scores. - See Also:
- valkey.io for details.
- Example:
// Assume key contains a set with 200 member-score pairs GlideString cursor = gs("0"); Object[] result; do { result = client.zscan(key1, cursor, ZScanOptionsBinary.builder().matchPattern(gs("*")).count(20L).build()).get(); cursor = gs(result[0].toString()); Object[] glideStringResults = (Object[]) result[1]; System.out.println("\nZSCAN iteration:"); for (int i = 0; i < glideStringResults.length; i += 2) { System.out.printf("{%s=%s}", glideStringResults[i], glideStringResults[i + 1]); if (i + 2 < glideStringResults.length) { System.out.print(", "); } } } while (!cursor.equals(gs("0")));
-
-