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

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

105次阅读
没有评论

共计 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字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 国产精品yjizz视频网一二区 | 日韩中文字幕精品一区在线 | 久久久久久久九九九九 | 狠狠色狠狠色88综合日日91 | 国产精品久久精品第一页 | 国产精品丝袜一区二区三区 | 无毛逼逼 | 性久久久久久 | 国产疯狂伦交大片 | 国产免费久久精品99 | 欧美大香a蕉免费 | 成人满18在线观看网站免费 | a毛片基地| 九九免费视频 | 无码日韩精品一区二区人妻 | 毛片一区二区三区 | 国内精品视频一区二区三区 | 在线视频亚洲欧美 | 欧美成人免费在线视频 | 亚洲精品久久久久一区二区 | 天堂а√在线最新版中文在线 | 91国内在线视频 | 最新欧美精品一区二区三区 | 天天天天天操 | 蜜桃视频在线观看www | 无码av中文字幕久久专区 | 久久亚洲国产中v天仙www | 清纯唯美亚洲综合 | 免费激情网站 | 精品综合久久久久久98 | 天天躁日日躁狠狠躁av中文 | 久久国产成人午夜av影院 | 亚洲成在人线av | 丰满多毛的大隂户毛茸茸 | 亚欧日韩| 成人影院一区二区三区 | 亚洲产在线精品第一站不卡 | 亚洲乱色熟女一区二区三区麻豆 | 在线天堂网 | 日本一区二区三区久久久久 | 亚洲天堂男人 |