Redis ZSet Type

Redis有序集合的操作命令和对应的api如下:


zadd [zset] sco 'value'
JedisAPI:public Long zadd(final String key, final double score, final String member)
功能:向zset中添加score为sco的value,如果value已存在,则仅修改score,同时返回0,否则返回1

zrange/zrangebyscore [zset] start end (wisthscores)
JedisAPI:public Set<String> zrange(final String key, final long start, final long end)
功能:返回zset中从索引start到end的元素,withscores可选是否同时显示元素对应的score

zrem [zset] 'value'
JedisAPI:public Long zrem(final String key, final String... member)
功能: 删除zset中值为value的元素

zincrby [zset] n 'value'
JedisAPI:public Double zincrby(final String key, final double score, final String member)
功能:如果zset中存在value,则令其score加n,否则添加value,令其score为n

zrank [zset] 'value'
JedisAPI:public Long zrank(final String key, final String member)
功能:返回zset中值为value的元素排名(按score从小到大)

zrevrank [zset] 'value'
JedisAPI:public Long zrevrank(final String key, final String member)
功能:按score从大到小返回元素排名

zrevrange [zset] start end
JedisAPI:public Set<String> zrevrange(final String key, final long start, final long end)
功能:返回zset[end…start]

zcount [zset] start end
JedisAPI:public Long zcount(final String key, final double min, final double max)
功能:返回zset在指定区间的数量

zcard [zset]
JedisAPI:public Long zcard(final String key)
功能:返回zset中元素的个数

zscore [zset] 'value'
JedisAPI:public Double zscore(final String key, final String member)
功能:返回值为value的元素的score

zremrangebyrank [zset] start end
JedisAPI:public Long zremrangeByRank(final String key, final long start, final long end)
功能:删除zset按score从小到大排序索引从start到end的元素。

zremrangebyscore [zset] score1 score2
JedisAPI:public Long zremrangeByScore(final String key, final double start, final double end)
功能:删除zset中score在score1到score2之间的元素

posted @ 2019-08-09 11:12  梦人亭  阅读(241)  评论(0编辑  收藏  举报