zset
成都创新互联专业为企业提供
黄龙网站建设、黄龙做网站、黄龙网站设计、黄龙网站制作等企业网站建设、网页设计与制作、黄龙企业网站模板建站服务,十载
黄龙做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。是string类型的有序集合
zadd:向名称为key的zset中添加元素member,score用于排序。如果该元素存在,则更新其顺序。
127.0.0.1:6379> zadd myzset 1 one
(integer) 1
127.0.0.1:6379> zadd myzset 2 two
(integer) 1
127.0.0.1:6379> zadd myzset 3 two
(integer) 0
127.0.0.1:6379> zrange myzset 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "3"
zrem:删除名称为key的zset中的元素member。
127.0.0.1:6379> zrange myzset 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "3"
127.0.0.1:6379> zrem myzset two
(integer) 1
127.0.0.1:6379> zrange myzset 0 -1 withscores
1) "one"
2) "1"
zincrby:如果在名称为key的zset中已经存在元素member,则该元素的score增加increment,否则向该集合中添加该元素,其score的值为increment。
127.0.0.1:6379> zadd myzset2 1 one
(integer) 1
127.0.0.1:6379> zadd myzset2 2 two
(integer) 1
127.0.0.1:6379> zrange myzset2 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
127.0.0.1:6379> zincrby myzset2 2 one
"3"
127.0.0.1:6379> zrange myzset2 0 -1 withscores
1) "two"
2) "2"
3) "one"
4) "3"
zrank:返回名称为key的zset中member元素的排名(按score从小到大排序)即下标。
127.0.0.1:6379> zadd myzset3 1 one
(integer) 1
127.0.0.1:6379> zadd myzset3 2 two
(integer) 1
127.0.0.1:6379> zadd myzset3 3 three
(integer) 1
127.0.0.1:6379> zadd myzset3 5 five
(integer) 1
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"
7) "five"
8) "5"
127.0.0.1:6379> zrank myzset3 two
(integer) 1
127.0.0.1:6379> zrank myzset3 three
(integer) 2
zrevrank:返回名称为key的zset中member元素的排名(按score从大到小排序)即下标
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"
7) "five"
8) "5"
127.0.0.1:6379> zrevrank myzset3 five
(integer) 0
zrevrange:
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"
7) "five"
8) "5"
127.0.0.1:6379> zrevrange myzset3 0 -1 withscores
1) "five"
2) "5"
3) "three"
4) "3"
5) "two"
6) "2"
7) "one"
8) "1"
zrangebyscore:
127.0.0.1:6379> zrangebyscore myzset3 2 3 withscores
1) "two"
2) "2"
3) "three"
4) "3"
zcount:
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"
7) "five"
8) "5"
127.0.0.1:6379> zcount myzset3 2 3
(integer) 2
zcard:
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"
7) "five"
8) "5"
127.0.0.1:6379> zcard myzset3
(integer) 4
zremrangebyrank:删除集合中排名在给定区间的元素。
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"
7) "five"
8) "5"
127.0.0.1:6379> zremrangebyrank myzset3 1 1
(integer) 1
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "three"
4) "3"
5) "five"
6) "5"
zremrangbyscore:
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "three"
4) "3"
5) "five"
6) "5"
127.0.0.1:6379> zremrangebyscore myzset3 4 5
(integer) 1
127.0.0.1:6379> zrange myzset3 0 -1 withscores
1) "one"
2) "1"
3) "three"
4) "3"
新闻名称:Redis之zset类型及操作-创新互联
网站地址:/article40/dshoho.html
成都网站建设公司_创新互联,为您提供标签优化、云服务器、微信小程序、全网营销推广、动态网站、定制网站
广告
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源:
创新互联