redis


Author: yifei / Created: June 8, 2017, 6:19 p.m. / Modified: June 8, 2017, 10:21 p.m. / Edit

zset

rank is which place the value ranked by score in the zset.

add and remove cookies

zadd KEY SCORE MEMBER           # add a value to a zset
zincrby KEY SCORE MEMBER        # increment the member's score NOTE redis-py implements wrongly
zrem KEY MEMBER...              # remove a value from zset
zremrangebyrank KEY START STOP  # removes all values in the set within the give index
zremrangebyscore KEY MIN MAX    # removes all values in the set within the given scores

get zset stats

this is zismember command, just use zscore KEY MEMBER is None to check

zcard KEY                       # get the number of elements in a zset
zcount KEY MIN MAX              # count the members in a sorted set with scores within the given scores
zrank KEY MEMBER                # get the index of member in zset
zrevrank KEY MEMBER             # the reverse index of member
zscore KEY MEMBER               # get the score of member in zset

read member(s)

zrange KEY START END            # a range of members by index
zrevrange KEY START END         # a range of memvers by index, sorted from high to low
zrangebyscore KEY MIN MAX       # a range of members within given scores
zrevrangebyscore KEY MAX MIN    # a range of members within given scores, from max to min

set manipulation


评论区