Redis Sorted sets

2069 ワード

Title: Redis Sorted sets date: 2015-05-05 13:08:36 +0800 comments: true category: Redis tags: redis,linux
Redis Sorted-Set
zadd
ZADD key score member [score member ...]
e.g.
    zadd myzset 1 one
# zrange myzset 0 -1 withscores

zrem
ZREM key member [member ...]
e.g.
    zrem myzset one

zrange
ZRANGE key start stop [WITHSCORES]
e.g.
    zrange myzset 0 -1 withscores

zrevrange
ZREVRANGE key start stop [WITHSCORES]
     key zset( score      )  index start end     

zincrby
ZINCRBY key increment member
      key zset       member,     score  increment;           , score   increment
e.g.
    zincrby key 3 one
    zincrby key 1 five
    127.0.0.1:6379[8]> ZRANGE myzset 0 -1 withscores
     1) "five"
     2) "1"
     3) "two"
     4) "2"
     5) "three"
     6) "3"
     7) "one"
     8) "4"
     9) "four"
    10) "7"

zrank
ZRANK key member
     key zset member     ( score      )   
e.g.
    127.0.0.1:6379[8]> ZRANGE myzset 0 -1 withscores
     1) "five"
     2) "1"
     3) "two"
     4) "2"
     5) "three"
     6) "3"
     7) "one"
     8) "4"
     9) "four"
    10) "7"
    127.0.0.1:6379[8]> zrank myzset five
    (integer) 0
    127.0.0.1:6379[8]> zrank myzset one
    (integer) 3

zrevrank
ZREVRANK key member
     key zset member     ( score      )   

zrangebyscore
ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
e.g.
    zrangebysocre myzset 2 4 withscores

zcount
ZCOUNT key min max
     score        
e.g.
    zcount key

zcard
    
ZCARD key

zscore
         score
ZSCORE key member

zremrangebyrank
zremrangebyscore