Programmer Reference : Redis : EsRedisSortedSetCommands
EsRedisSortedSetCommands
Description
Provides an API for the Redis Sorted Set commands. Sorted sets are a data type which is similar to a mix between a Set and a Hash. Like sets, sorted sets are composed of unique, non-repeating string elements. However, while elements inside sets are not ordered, every element in a sorted set is associated with a floating point value, called the score.
This command group is accessed via EsRedisClient>>sortedSets.
Class Methods
None
Instance Methods
bzmpop:numkeys:keys:from:count:
  Blocking version of ZMPOP.
    
     Arguments:
        aTimeout - <Number> Timeout in seconds.
        aNumkeys - <Integer> Number of keys to scan.
        aKeys - <Collection of String> The keys to examine.
        aFrom - <String> Either 'MIN' or 'MAX'.
        aCount - <Integer> The number of elements to pop.
     Answers:
        <Array> An array with the key name and a nested array of member-score pairs
                (scores as Numbers), e.g., #(keyName #((member1 score1) ...)).
        <EsFuture> In async mode, a future that completes with the result.
bzpopmax:timeout:
  Remove and return the member with the highest score from one of the sorted sets, blocking until one is available.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
        anInteger - <Integer> The timeout in seconds.
     Answers:
        <Array> A three-element array with the key, member, and score (as a Number), or nil on timeout.
        <EsFuture> In async mode, a future that completes with the result.
bzpopmin:timeout:
  Remove and return the member with the lowest score from one of the sorted sets, blocking until one is available.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
        anInteger - <Integer> The timeout in seconds.
     Answers:
        <Array> A three-element array with the key, member, and score (as a Number), or nil on timeout.
        <EsFuture> In async mode, a future that completes with the result.
zadd:score:member:
  Add one member to a sorted set, or update its score if it already exists.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        aNumber - <Number> The score for the member.
        aMember - <Object> The member to add.
     Answers:
        <Integer> The number of elements added to the sorted set (1 or 0).
        <EsFuture> In async mode, a future that completes with the result.
zadd:scoresAndMembers:
  Add one or more members to a sorted set, or update their scores if they already exist.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        aDictionary - <Dictionary> A dictionary where keys are members and values are scores.
     Answers:
        <Integer> The number of elements added to the sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zadd:scoresAndMembers:options:
  Add one or more members to a sorted set, with options.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        aDictionary - <Dictionary> A dictionary where keys are members and values are scores.
        aCollectionOfOptions - <Collection> Optional arguments like NX, XX, GT, LT, CH, INCR.
     Answers:
        <Integer> The number of elements added or updated.
        <EsFuture> In async mode, a future that completes with the result.
zcard:
  Get the number of members in a sorted set.
     
     Arguments:
        aKey - <String> The key of the sorted set.
     Answers:
        <Integer> The cardinality (number of elements) of the sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zcount:min:max:
  Count the members in a sorted set with scores within the given values.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        minNumber - <Number> The minimum score.
        maxNumber - <Number> The maximum score.
     Answers:
        <Integer> The number of elements in the specified score range.
        <EsFuture> In async mode, a future that completes with the result.
zdiff:
  Return the difference between the first and subsequent sorted sets.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Array> An array of members of the resulting set.
        <EsFuture> In async mode, a future that completes with the result.
zdiff:withScores:
  Return the difference between the first and subsequent sorted sets, optionally with scores.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
        aBoolean - <Boolean> If true, return scores as well.
     Answers:
        <Array> An array of members, or member-score pairs (scores as Numbers).
                The reply is normalized to a flat array: #(member1 score1 member2 score2...).
        <EsFuture> In async mode, a future that completes with the result.
zdiffstore:keys:
  Compute the difference between sorted sets and store the result in a new key.
    
     Arguments:
        aDestKey - <String> The destination key.
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Integer> The number of elements in the resulting sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zincrby:increment:member:
  Increment the score of a member in a sorted set.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        aNumber - <Number> The amount to increment the score by.
        aMember - <Object> The member whose score to increment.
     Answers:
        <Number> The new score of the member.
        <EsFuture> In async mode, a future that completes with the result.
zinter:
  Intersect multiple sorted sets and return the resulting sorted set.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Array> The resulting sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zintercard:
  Intersect multiple sorted sets and return the cardinality of the intersection.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Integer> The number of elements in the resulting intersection.
        <EsFuture> In async mode, a future that completes with the result.
zinterstore:keys:
  Intersect multiple sorted sets and store the resulting sorted set in a new key.
    
     Arguments:
        aDestKey - <String> The destination key.
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Integer> The number of elements in the resulting sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zlexcount:min:max:
  Count the members in a sorted set between a given lexicographical range.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        minString - <String> The minimum lexicographical value (e.g., '[a', '(b').
        maxString - <String> The maximum lexicographical value.
     Answers:
        <Integer> The number of members in the specified lexicographical range.
        <EsFuture> In async mode, a future that completes with the result.
zmpop:keys:from:count:
  Pops one or more elements from the first non-empty sorted set from a list of keys.
    
     Arguments:
        aNumkeys - <Integer> The number of keys.
        aKeys - <Collection of String> The sorted set keys to check.
        aFrom - <String> 'MIN' or 'MAX'.
        aCount - <Integer> The number of elements to pop.
     Answers:
        <Array> An array with the key name and a nested array of member-score pairs
                (scores as Numbers), e.g., #(keyName #((member1 score1) ...)).
        <EsFuture> In async mode, a future that completes with the result.
zmscore:members:
  Get the scores associated with the given members in a sorted set.
    
    Arguments:
        aKey - <String> The key of the sorted set.
        aCollectionOfMembers - <Collection> The members whose scores to get.
    Answers:
        <Array> The scores of the members (as Numbers), or nil if a member does not exist.
        <EsFuture> In async mode, a future that completes with the result.
zpopmax:
  Remove and return the member with the highest score from a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
     Answers:
        <Array> A two-element array containing the member and its score (as a Number).
        <EsFuture> In async mode, a future that completes with the result.
zpopmax:count:
  Remove and return one or more members with the highest scores from a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        anInteger - <Integer> The number of members to pop.
     Answers:
        <Array> An array of members and their scores (as Numbers), normalized to a flat array.
        <EsFuture> In async mode, a future that completes with the result.
zpopmin:
  Remove and return the member with the lowest score from a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
     Answers:
        <Array> A two-element array containing the member and its score (as a Number).
        <EsFuture> In async mode, a future that completes with the result.
zpopmin:count:
  Remove and return one or more members with the lowest scores from a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        anInteger - <Integer> The number of members to pop.
     Answers:
        <Array> An array of members and their scores (as Numbers), normalized to a flat array.
        <EsFuture> In async mode, a future that completes with the result.
zrandmember:
  Get a random member from a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
     Answers:
        <String> A random member.
        <EsFuture> In async mode, a future that completes with the result.
zrandmember:count:
  Get one or more random members from a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        anInteger - <Integer> The number of members to return.
     Answers:
        <Array> An array of random members.
        <EsFuture> In async mode, a future that completes with the result.
zrandmember:count:withScores:
  Get one or more random members from a sorted set, optionally with scores.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        anInteger - <Integer> The number of members to return.
        aBoolean - <Boolean> If true, return scores as well.
     Answers:
        <Array> An array of random members, or member-score pairs (scores as Numbers),
                normalized to a flat array.
        <EsFuture> In async mode, a future that completes with the result.
zrange:start:stop:
  Return a range of members in a sorted set, by index.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        startInteger - <Integer> The starting zero-based index.
        stopInteger - <Integer> The ending zero-based index.
     Answers:
        <Array> An array of members within the specified range.
        <EsFuture> In async mode, a future that completes with the result.
zrange:start:stop:withScores:
  Return a range of members in a sorted set, by index, optionally with scores.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        startInteger - <Integer> The starting zero-based index.
        stopInteger - <Integer> The ending zero-based index.
        aBoolean - <Boolean> If true, return scores as well.
     Answers:
        <Array> An array of members, or an array of member-score pairs (scores as Numbers),
                normalized to a flat array.
        <EsFuture> In async mode, a future that completes with the result.
zrangebylex:min:max:
  Return a range of members in a sorted set, by lexicographical range.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        minString - <String> The minimum lexicographical value.
        maxString - <String> The maximum lexicographical value.
     Answers:
        <Array> An array of members in the specified range.
        <EsFuture> In async mode, a future that completes with the result.
zrangebyscore:min:max:
  Return a range of members in a sorted set, by score.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        aMin - <Object> The minimum score. Can be a Number or a String (e.g., '(10').
        aMax - <Object> The maximum score. Can be a Number or a String.
     Answers:
        <Array> An array of members in the specified score range.
        <EsFuture> In async mode, a future that completes with the result.
zrank:member:
  Determine the index of a member in a sorted set.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        aMember - <Object> The member to get the rank of.
     Answers:
        <Integer> The zero-based rank of the member, or nil if the member does not exist.
        <EsFuture> In async mode, a future that completes with the result.
zrem:members:
  Remove one or more members from a sorted set.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        aMemberOrCollection - <Object | SequenceableCollection> The member or members to remove.
     Answers:
        <Integer> The number of members removed from the sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zremrangebylex:min:max:
  Remove all members in a sorted set between the given lexicographical range.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        minString - <String> The minimum lexicographical value.
        maxString - <String> The maximum lexicographical value.
     Answers:
        <Integer> The number of members removed.
        <EsFuture> In async mode, a future that completes with the result.
zremrangebyrank:start:stop:
  Remove all members in a sorted set within the given ranks.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        startInteger - <Integer> The starting rank.
        stopInteger - <Integer> The stopping rank.
     Answers:
        <Integer> The number of members removed.
        <EsFuture> In async mode, a future that completes with the result.
zremrangebyscore:min:max:
  Remove all members in a sorted set within the given scores.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        minString - <String> The minimum score (e.g., '1.5', '(1.5').
        maxString - <String> The maximum score.
     Answers:
        <Integer> The number of members removed.
        <EsFuture> In async mode, a future that completes with the result.
zrevrange:start:stop:
  Return a range of members in a sorted set, by index, with scores ordered from high to low.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        startInteger - <Integer> The starting index.
        stopInteger - <Integer> The stopping index.
     Answers:
        <Array> An array of members.
        <EsFuture> In async mode, a future that completes with the result.
zrevrangebylex:max:min:
  Return a range of members in a sorted set, by lexicographical range, ordered from high to low.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        maxString - <String> The maximum lexicographical value.
        minString - <String> The minimum lexicographical value.
     Answers:
        <Array> An array of members.
        <EsFuture> In async mode, a future that completes with the result.
zrevrangebyscore:max:min:
  Return a range of members in a sorted set, by score, with scores ordered from high to low.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        maxString - <String> The maximum score.
        minString - <String> The minimum score.
     Answers:
        <Array> An array of members.
        <EsFuture> In async mode, a future that completes with the result.
zrevrank:member:
  Determine the rank of a member in a sorted set, with scores ordered from high to low.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        aMember - <Object> The member to get the rank of.
     Answers:
        <Integer> The rank of the member, or nil if the member does not exist.
        <EsFuture> In async mode, a future that completes with the result.
zscan:cursor:
  Incrementally iterate members and scores of a sorted set.
    
     Arguments:
        aKey - <String> The key of the sorted set.
        aCursor - <String> The cursor.
     Answers:
        <Array> An array where the first element is the new cursor, and the second is an array of member-score pairs.
        <EsFuture> In async mode, a future that completes with the result.
zscore:member:
  Get the score associated with the given member in a sorted set.
     
     Arguments:
        aKey - <String> The key of the sorted set.
        aMember - <Object> The member whose score to get.
     Answers:
        <Number> The score of the member, or nil if the member does not exist.
        <EsFuture> In async mode, a future that completes with the result.
zunion:
  Add multiple sorted sets and return the resulting sorted set.
    
     Arguments:
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Array> The resulting sorted set.
        <EsFuture> In async mode, a future that completes with the result.
zunionstore:keys:
  Add multiple sorted sets and store the resulting sorted set in a new key.
    
     Arguments:
        aDestKey - <String> The destination key.
        aCollectionOfKeys - <Collection> The keys of the sorted sets.
     Answers:
        <Integer> The number of elements in the resulting sorted set.
        <EsFuture> In async mode, a future that completes with the result.
Last modified date: 01/22/2026