在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

redis中lpush、rpush、lset、lrem是什么

115次阅读
没有评论

共计 1914 个字符,预计需要花费 5 分钟才能阅读完成。

自动写代码机器人,免费开通

丸趣 TV 小编给大家分享一下 redis 中 lpush、rpush、lset、lrem 是什么,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

1.lpush

在 key 对应 list 的头部添加字符串元素

2.rpush

在 key 对应 list 的尾部添加字符串元素

3.linsert

在 key 对应 list 的特定位置之前或之后添加字符串元素

redis 127.0.0.1:6379 rpush mylist3 hello 
(integer) 1
redis 127.0.0.1:6379 rpush mylist3 world 
(integer) 2
redis 127.0.0.1:6379 linsert mylist3 before world there 
(integer) 3
redis 127.0.0.1:6379 lrange mylist3 0 -1
1) hello 
2) there 
3) world 
redis 127.0.0.1:6379

在此处我们先插入了一个 hello,然后在 hello 的尾部插入了一个 world,然后又在 world 的

前面插入了 there。

4.lset

设置 list 中指定下标的元素值 (下标从 0 开始)

redis 127.0.0.1:6379 rpush mylist4 one 
(integer) 1
redis 127.0.0.1:6379 rpush mylist4 two 
(integer) 2
redis 127.0.0.1:6379 rpush mylist4 three 
(integer) 3
redis 127.0.0.1:6379 lset mylist4 0 four 
redis 127.0.0.1:6379 lset mylist4 -2 five 
redis 127.0.0.1:6379 lrange mylist4 0 -1
1) four 
2) five 
3) three 
redis 127.0.0.1:6379

在此处我们依次插入了 one,two,three,然后将标是 0 的值设置为 four,再将下标是 - 2 的值设

置为 five。

5.lrem

从 key 对应 list 中删除 count 个和 value 相同的元素。

count 0 时,按从头到尾的顺序删除,具体如下:

redis 127.0.0.1:6379 rpush mylist5 hello 
(integer) 1
redis 127.0.0.1:6379 rpush mylist5 hello 
(integer) 2
redis 127.0.0.1:6379 rpush mylist5 foo 
(integer) 3
redis 127.0.0.1:6379 rpush mylist5 hello 
(integer) 4
redis 127.0.0.1:6379 lrem mylist5 2 hello 
(integer) 2
redis 127.0.0.1:6379 lrange mylist5 0 -1
1) foo 
2) hello 
redis 127.0.0.1:6379

count 0 时,按从尾到头的顺序删除,具体如下:

redis 127.0.0.1:6379 rpush mylist6 hello 
(integer) 1
redis 127.0.0.1:6379 rpush mylist6 hello 
(integer) 2
redis 127.0.0.1:6379 rpush mylist6 foo 
(integer) 3
redis 127.0.0.1:6379 rpush mylist6 hello 
(integer) 4
redis 127.0.0.1:6379 lrem mylist6 -2 hello 
(integer) 2
redis 127.0.0.1:6379 lrange mylist6 0 -1
1) hello 
2) foo 
redis 127.0.0.1:6379

count=0 时,删除全部,具体如下:

redis 127.0.0.1:6379 rpush mylist7 hello 
(integer) 1
redis 127.0.0.1:6379 rpush mylist7 hello 
(integer) 2
redis 127.0.0.1:6379 rpush mylist7 foo 
(integer) 3
redis 127.0.0.1:6379 rpush mylist7 hello 
(integer) 4
redis 127.0.0.1:6379 lrem mylist7 0 hello 
(integer) 3
redis 127.0.0.1:6379 lrange mylist7 0 -1
1) foo 
redis 127.0.0.1:6379

看完了这篇文章,相信你对 redis 中 lpush、rpush、lset、lrem 是什么有了一定的了解,想了解更多相关知识,欢迎关注丸趣 TV 行业资讯频道,感谢各位的阅读!

向 AI 问一下细节

丸趣 TV 网 – 提供最优质的资源集合!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-12-18发表,共计1914字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 成人精品一区久久久久 | 四虎在线网站 | 欧美男人天堂网 | 国产三香港三韩国三级不卡 | 国产精品乱 | 国产美女mm131爽爽爽免费 | 久久午夜夜伦鲁鲁片免费无码影视 | 色老头在线一区二区三区 | 99久久精品费精品国产一区二区 | 97人妻无码一区二区精品免费 | 亚洲精品久久激情国产片 | 国产精品后入内射日本在线观看 | 大地资源中文第3页 | 久久777国产线看观看精品 | 最近免费中文字幕 | 闲人吧综合免费888精品 | 玩弄白嫩少妇xxxxx性 | 真人毛片免费观看视频 | 黑人粗硬进入过程视频 | 欧美老妇疯狂xxxxbbbb | 欧美一区亚洲二区 | 久久黄色录像 | 五月激情婷婷综合 | 久热免费在线视频 | 18成人片黄网站www | 亚洲精品乱码久久久久 | 成人毛片在线视频 | 国产剧情麻豆女教师在线观看 | 国产成人一区在线播放 | 亚洲男人av香蕉爽爽爽爽 | 亚洲国产香蕉碰碰人人 | 99久久久无码国产精品 | 国产精品99久久99久久久看片 | 精品一区二区三区在线观看l | 国产一区二区三区久久 | 亚洲色av性色在线观无码 | 五月丁香六月激情综合在线视频 | 韩国免费高清一级 | 男女啪啪成人免费网站 | 国产成人精品日本亚洲11 | 人人爽人人爽人人爽人人片av |