On this page:
redis-zset-add!
redis-zset-count
redis-zset-count/  lex
redis-zset-incr!
redis-zset-intersect!
redis-zset-pop/  max!
redis-zset-pop/  min!
redis-zset-rank
redis-zset-remove!
redis-zset-remove/  lex!
redis-zset-remove/  rank!
redis-zset-remove/  score!
redis-zset-scan
redis-zset-score
redis-zset-union!
redis-subzset
redis-subzset/  lex
redis-subzset/  score
in-redis-zset

16 Sorted Set Commands🔗ℹ

procedure

(redis-zset-add! client    
  key    
  member ...+    
  score ...+)  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  member : redis-string/c
  score : real?
Adds each member with its associated score to the sorted set at key.
Commands used by this function: ZADD

procedure

(redis-zset-count client    
  key    
  [#:min min    
  #:max max])  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  min : real? = #f
  max : real? = #f
Counts the number of elements within the sorted set at key.
Commands used by this function: ZCARD, ZCOUNT

procedure

(redis-zset-count/lex client    
  key    
  [#:min min    
  #:max max])  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  min : redis-string/c = #"-"
  max : redis-string/c = #"+"
Counts the number of elements within the sorted set at key according to a lexicographic sort of the set members.
Commands used by this function: ZLEXCOUNT

procedure

(redis-zset-incr! client key member [n])  real?

  client : redis?
  key : redis-key/c
  member : redis-string/c
  n : real? = 1
Increments member’s score within the sorted set at key by n.
Commands used by this function: ZINCRBY

procedure

(redis-zset-intersect! client 
  dest 
  key ...+ 
  [#:weights weights 
  #:aggregate aggregate]) 
  exact-nonnegative-integer?
  client : redis?
  dest : redis-key/c
  key : redis-key/c
  weights : (non-empty-listof real?) = #f
  aggregate : (or/c 'sum 'min 'max) = 'sum
Stores the intersection of all the sorted sets at the given keys into dest.
Commands used by this function: ZINTERSTORE

procedure

(redis-zset-pop/max! client 
  key ... 
  [#:count count 
  #:block? block? 
  #:timeout timeout]) 
  
(or/c #f
      (list/c bytes? bytes? real?)
      (listof (cons/c bytes? real?)))
  client : redis?
  key : redis-key/c
  count : exact-positive-integer? = 1
  block? : boolean? = #f
  timeout : exact-nonnegative-integer? = 0
When block? is #t, a count cannot be provided and the result will either be #f in case the timeout was reached or a list containing the name of the key that was popped, the name of the member and the member’s score.

When block? is #f, a single key may be provided, but count can be positive. The result will be an association list containing each popped member and its associated score.
Commands used by this function: BZPOPMAX, ZPOPMAX

procedure

(redis-zset-pop/min! client 
  key ... 
  [#:count count 
  #:block? block? 
  #:timeout timeout]) 
  
(or/c #f
      (list/c bytes? bytes? real?)
      (listof (cons/c bytes? real?)))
  client : redis?
  key : redis-key/c
  count : exact-positive-integer? = 1
  block? : boolean? = #f
  timeout : exact-nonnegative-integer? = 0
When block? is #t, a count cannot be provided and the result will either be #f in case the timeout was reached or a list containing the name of the key that was popped, the name of the member and the member’s score.

When block? is #f, a single key may be provided, but count can be positive. The result will be an association list containing each popped member and its associated score.
Commands used by this function: BZPOPMIN, ZPOPMIN

procedure

(redis-zset-rank client 
  key 
  member 
  [#:reverse? reverse?]) 
  (or/c #f exact-nonnegative-integer?)
  client : redis?
  key : redis-key/c
  member : redis-string/c
  reverse? : boolean? = #f
Returns the rank of member within the sorted set at key. If member is not in the set, then #f is returned.

If reverse? is #t, then the reverse rank of member is returned.
Commands used by this function: ZRANK, ZREVRANK

procedure

(redis-zset-remove! client key member ...+)

  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  member : redis-string/c
Removes each member from the sorted set at key.
Commands used by this function: ZREM

procedure

(redis-zset-remove/lex! client    
  key    
  [#:min min    
  #:max max])  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  min : redis-string/c = "-"
  max : redis-string/c = "+"
Removes all of the lexicographically-sorted members between min and max from the sorted set at key and returns the total number of elements that were removed.
Commands used by this function: ZREMRANGEBYLEX

procedure

(redis-zset-remove/rank! client 
  key 
  [#:start start 
  #:stop stop]) 
  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  start : exact-integer? = 0
  stop : exact-integer? = -1
Removes all of the members whose indices are within the inclusive range between start and stop from the sorted set at key and returns the total number of elements that were removed.
Commands used by this function: ZREMRANGEBYRANK

procedure

(redis-zset-remove/score! client 
  key 
  [#:start start 
  #:stop stop]) 
  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  start : real? = -inf.0
  stop : real? = +inf.0
Removes all of the members whose scores are within the inclusive range between start and stop from the sorted set at key and returns the total number of elements that were removed.
Commands used by this function: ZREMRANGEBYSCORE

procedure

(redis-zset-scan client 
  key 
  [#:cursor cursor 
  #:pattern pattern 
  #:limit limit]) 
  
exact-nonnegative-integer?
(listof (cons/c redis-string/c real?))
  client : redis?
  key : redis-key/c
  cursor : exact-nonnegative-integer? = 0
  pattern : (or/c #f redis-string/c) = #f
  limit : (or/c #f exact-positive-integer?) = #f
Efficiently iterates through the members and their associated scores in the sorted set at key.

The limit parameter serves as a hint for the implementation, but the server may return more items than limit per iteration.
Commands used by this function: ZSCAN

procedure

(redis-zset-score client key member)  (or/c #f real?)

  client : redis?
  key : redis-key/c
  member : redis-string/c
Returns the score of member from the sorted set at key or #f if member isn’t in the set.
Commands used by this function: ZSCORE

procedure

(redis-zset-union! client 
  dest 
  key ...+ 
  [#:weights weights 
  #:aggregate aggregate]) 
  exact-nonnegative-integer?
  client : redis?
  dest : redis-key/c
  key : redis-key/c
  weights : (non-empty-listof real?) = #f
  aggregate : (or/c 'sum 'min 'max) = 'sum
Stores the union of all the sorted sets at the given keys into dest.
Commands used by this function: ZUNIONSTORE

procedure

(redis-subzset client 
  key 
  [#:reverse? reverse? 
  #:start start 
  #:stop stop 
  #:include-scores? scores?]) 
  
(or/c (listof bytes?)
      (listof (cons/c bytes? real?)))
  client : redis?
  key : redis-key/c
  reverse? : boolean? = #f
  start : exact-integer? = 0
  stop : exact-integer? = -1
  scores? : boolean? = #f
Retrieves the members between the inclusive indices start and stop from the sorted set at key. If reverse? is #t, then the elements are sorted in reverse before retrieval.

When scores? is #t, the result contains an alist mapping members to their scores.
Commands used by this function: ZRANGE, ZREVRANGE

procedure

(redis-subzset/lex client    
  key    
  [#:reverse? reverse?    
  #:min min    
  #:max max    
  #:limit limit    
  #:offset offset])  (listof bytes?)
  client : redis?
  key : redis-key/c
  reverse? : boolean? = #f
  min : redis-string/c = #"-"
  max : redis-string/c = #"+"
  limit : exact-positive-integer? = #f
  offset : exact-nonnegative-integer? = 0
Retrieves the lexicographically-sorted set of members between min and max from the sorted set at key. If reverse? is #t, then the elements are sorted in reverse before retrieval.
Commands used by this function: ZRANGEBYLEX, ZREVRANGEBYLEX

procedure

(redis-subzset/score client 
  key 
  [#:reverse? reverse? 
  #:include-scores? scores? 
  #:start start 
  #:stop stop 
  #:limit limit 
  #:offset offset]) 
  
(or/c (listof bytes?)
      (listof (cons/c bytes? real?)))
  client : redis?
  key : redis-key/c
  reverse? : boolean? = #f
  scores? : boolean? = #f
  start : real? = -inf.0
  stop : real? = +inf.0
  limit : exact-positive-integer? = #f
  offset : exact-nonnegative-integer? = 0
Retrieves the of members whose scores are between start and stop from the sorted set at key. When reverse? is #t, then the elements are sorted in reverse before retrieval.

When scores? is #t, the result contains an alist mapping members to their scores.
Commands used by this function: ZRANGEBYSCORE, ZREVRANGEBYSCORE

procedure

(in-redis-zset client key)  (sequence/c (cons/c bytes? real?))

  client : redis?
  key : redis-key/c
Returns a sequence that can be used to efficiently iterate through the sorted set at key.

Any keyword arguments that are passed to this function will be forwarded to redis-zset-scan.