2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-01 21:40:24 +00:00
cheat.sheets/sheets/_redis/sorted_set

64 lines
2.3 KiB
Plaintext
Raw Normal View History

2018-05-19 20:40:36 +00:00
# Add one or more members to a sorted set, or update its score if it already exists
ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
# Get the number of members in a sorted set
ZCARD key
# Count the members in a sorted set with scores within the given values
ZCOUNT key min max
# Increment the score of a member in a sorted set
ZINCRBY key increment member
# Intersect multiple sorted sets and store the resulting sorted set in a new key
ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
# Count the number of members in a sorted set between a given lexicographical range
ZLEXCOUNT key min max
# Return a range of members in a sorted set, by index
ZRANGE key start stop [WITHSCORES]
# Return a range of members in a sorted set, by lexicographical range
ZRANGEBYLEX key min max [LIMIT offset count]
# Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.
ZREVRANGEBYLEX key max min [LIMIT offset count]
# Return a range of members in a sorted set, by score
ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
# Determine the index of a member in a sorted set
ZRANK key member
# Remove one or more members from a sorted set
ZREM key member [member ...]
# Remove all members in a sorted set between the given lexicographical range
ZREMRANGEBYLEX key min max
# Remove all members in a sorted set within the given indexes
ZREMRANGEBYRANK key start stop
# Remove all members in a sorted set within the given scores
ZREMRANGEBYSCORE key min max
# Return a range of members in a sorted set, by index, with scores ordered from high to low
ZREVRANGE key start stop [WITHSCORES]
# Return a range of members in a sorted set, by score, with scores ordered from high to low
ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
# Determine the index of a member in a sorted set, with scores ordered from high to low
ZREVRANK key member
# Get the score associated with the given member in a sorted set
ZSCORE key member
# Add multiple sorted sets and store the resulting sorted set in a new key
ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
# Incrementally iterate sorted sets elements and associated scores
ZSCAN key cursor [MATCH pattern] [COUNT count]