当前位置: 首页 > news >正文

清远最新消息孔宇seo

清远最新消息,孔宇seo,phpnow 搭建网站,asp网站建设教程文章目录 list(数组)(1)添加子成员(2)基于索引获取列表成员(3)获取列表的切片(4)获取列表的长度(5)按索引设置值(6&#x…

文章目录

  • list(数组)
    • (1)添加子成员
    • (2)基于索引获取列表成员
    • (3)获取列表的切片
    • (4)获取列表的长度
    • (5)按索引设置值
    • (6)删除指定成员

list(数组)

队列,列表的子成员类型为string

lpush key value

rpush key value

linsert key after|before 指定元素 value

lindex key index

lrange key start stop

lset key index value

lrem key count value

127.0.0.1:6379> lpush names ww zs ls
(integer) 3
127.0.0.1:6379> type names
list
127.0.0.1:6379> lrange names 0 -1
1) "ls"
2) "zs"
3) "ww"
127.0.0.1:6379> rpush names a b c
(integer) 6
127.0.0.1:6379> lrange names 0 -1
1) "ls"
2) "zs"
3) "ww"
4) "a"
5) "b"
6) "c"
127.0.0.1:6379> lpush names x y
(integer) 8
127.0.0.1:6379> lrange names 0 -1
1) "y"
2) "x"
3) "ls"
4) "zs"
5) "ww"
6) "a"
7) "b"
8) "c"

(1)添加子成员

# 在左侧(前)添加一条或多条数据
lpush key value1 value2 ...
# 在右侧(后)添加一条或多条数据
rpush key value1 value2 ...# 在指定元素的左边(前)/右边(后)插入一个或多个数据
linsert key before 指定元素 value1 value2 ....
linsert key after 指定元素 value1 value2 ....

从键为brother的列表左侧添加一个或多个数据liubei、guanyu、zhangfei

lpush brother liubei
# [liubei]
lpush brother guanyu zhangfei xiaoming
# [xiaoming,zhangfei,guanyu,liubei]

从键为brother的列表右侧添加一个或多个数据,xiaohong,xiaobai,xiaohui

rpush brother xiaohong
# [xiaoming,zhangfei,guanyu,liubei,xiaohong]
rpush brother xiaobai xiaohui
# [xiaoming,zhangfei,guanyu,liubei,xiaohong,xiaobai,xiaohui]

从key=brother的xiaohong的列表位置左侧添加一个数据,xiaoA,xiaoB

linsert brother before xiaohong xiaoA
# [xiaoming,zhangfei,guanyu,liubei,xiaoA,xiaohong,xiaobai,xiaohui]
linsert brother before xiaohong xiaoB
# [xiaoming,zhangfei,guanyu,liubei,xiaoA,xiaoB,xiaohong,xiaobai,xiaohui]

从key=brother,key=xiaohong的列表位置右侧添加一个数据,xiaoC,xiaoD

linsert brother after xiaohong xiaoC
# [xiaoming,zhangfei,guanyu,liubei,xiaoA,xiaohong,xiaoC,xiaobai,xiaohui]
linsert brother after xiaohong xiaoD
# [xiaoming,zhangfei,guanyu,liubei,xiaoA,xiaohong,xiaoD,xiaoC,xiaobai,xiaohui]

注意:当列表如果存在多个成员值一致的情况下,默认只识别第一个。

127.0.0.1:6379> linsert brother before xiaoA xiaohong
# [xiaoming,zhangfei,guanyu,liubei,xiaohong,xiaoA,xiaohong,xiaoD,xiaoC,xiaobai,xiaohui]
127.0.0.1:6379> linsert brother before xiaohong xiaoE
# [xiaoming,zhangfei,guanyu,liubei,xiaoE,xiaohong,xiaoA,xiaohong,xiaoD,xiaoC,xiaobai,xiaohui]
127.0.0.1:6379> linsert brother after xiaohong xiaoF
# [xiaoming,zhangfei,guanyu,liubei,xiaoE,xiaohong,xiaoF,xiaoA,xiaohong,xiaoD,xiaoC,xiaobai,xiaohui]

(2)基于索引获取列表成员

根据指定的索引(下标)获取成员的值,负数下标从右边-1开始,逐个递减

lindex key index

获取brother下标为2以及-2的成员

del brother
lpush brother guanyu zhangfei xiaoming
lindex brother 2
# "guanyu"
lindex brother -2
# "zhangfei"

(3)获取列表的切片

闭区间[包括stop]

lrange key start stop

操作:

del brother
rpush brother liubei guanyu zhangfei xiaoming xaiohong
# 获取btother的全部成员
lrange brother 0 -1
# 获取brother的前2个成员
lrange brother 0 1
# 获取brother的后2个成员
lrange brother -2 -1
127.0.0.1:6379> linsert names after "y" 10
(integer) 9
127.0.0.1:6379> lrange names 0 -1
1) "y"
2) "10"
3) "x"
4) "ls"
5) "zs"
6) "ww"
7) "a"
8) "b"
9) "c"127.0.0.1:6379> linsert names before "y" 20
(integer) 10
127.0.0.1:6379> lrange names 0 -11) "20"2) "y"3) "10"4) "x"5) "ls"6) "zs"7) "ww"8) "a"9) "b"
10) "c"127.0.0.1:6379> lindex names 3
"x"
127.0.0.1:6379> lindex names 0
"20"
127.0.0.1:6379> lindex names -1
"c"127.0.0.1:6379> lrange names 0 1
1) "20"
2) "y"
127.0.0.1:6379> lrange names -2 -1
1) "b"
2) "c"
127.0.0.1:6379>

(4)获取列表的长度

llen key

获取brother列表的成员个数

llen brother

(5)按索引设置值

lset key index value
# 注意:
# redis的列表也有索引,从左往右,从0开始,逐一递增,第1个元素下标为0
# 索引可以是负数,表示尾部开始计数,如`-1`表示最后1个元素

修改键为brother的列表中下标为4的元素值为xiaohongmao

lset brother 4 xiaohonghong

(6)删除指定成员

移除并获取列表的第一个成员或最后一个成员

lpop key  # 第一个成员出列
rpop key  # 最后一个成员出列

获取并移除brother中的第一个成员

lpop brother
# 开发中往往使用rpush和lpop实现队列的数据结构->实现入列和出列
lrem key count value# 注意:
# count表示删除的数量,value表示要删除的成员。该命令默认表示将列表从左侧前count个value的元素移除
# count==0,表示删除列表所有值为value的成员
# count >0,表示删除列表左侧开始的前count个value成员
# count <0,表示删除列表右侧开始的前count个value成员del brother
rpush brother A B A C A
lrem brother 0 A
["B","C"]del brother
rpush brother A B A C A
lrem brother -2 A
["A","B","C"]del brother
rpush brother A B A C A
lrem brother 2 A
["B","C","A"]
127.0.0.1:6379> llen names
(integer) 10
127.0.0.1:6379> lset names 9 cc
OK
127.0.0.1:6379> lrange names 0 -11) "20"2) "y"3) "10"4) "x"5) "ls"6) "zs"7) "ww"8) "a"9) "b"
10) "cc"
127.0.0.1:6379> lpop names
"20"
127.0.0.1:6379> lrange names 0 -1
1) "y"
2) "10"
3) "x"
4) "ls"
5) "zs"
6) "ww"
7) "a"
8) "b"
9) "cc"127.0.0.1:6379> rpop names
"cc"
127.0.0.1:6379> lrange names 0 -1
1) "y"
2) "10"
3) "x"
4) "ls"
5) "zs"
6) "ww"
7) "a"
8) "b"
127.0.0.1:6379> rpush namaes x
(integer) 1
127.0.0.1:6379> lrange names 0 -1
1) "y"
2) "10"
3) "x"
4) "ls"
5) "zs"
6) "ww"
7) "a"
8) "b"
127.0.0.1:6379> rpush names x
(integer) 9
127.0.0.1:6379> lrange namaes 0 -1
1) "x"
127.0.0.1:6379> lrem names -1 x
(integer) 1
127.0.0.1:6379> lrange names 0 -1
1) "y"
2) "10"
3) "x"
4) "ls"
5) "zs"
6) "ww"
7) "a"
8) "b"
127.0.0.1:6379>

文章转载自:
http://wanjiaplatysma.spfh.cn
http://wanjiamelancholiac.spfh.cn
http://wanjiasupersubstantial.spfh.cn
http://wanjiakpelle.spfh.cn
http://wanjialathyrism.spfh.cn
http://wanjiasloak.spfh.cn
http://wanjiaiv.spfh.cn
http://wanjiaslicker.spfh.cn
http://wanjiaecchymosis.spfh.cn
http://wanjiadiazonium.spfh.cn
http://wanjiaamphipath.spfh.cn
http://wanjiaabashment.spfh.cn
http://wanjiareappraisal.spfh.cn
http://wanjiapickup.spfh.cn
http://wanjiaraceball.spfh.cn
http://wanjiaforeseen.spfh.cn
http://wanjiawobbler.spfh.cn
http://wanjiaeelfare.spfh.cn
http://wanjiaheavier.spfh.cn
http://wanjiakeynotes.spfh.cn
http://wanjiaentryman.spfh.cn
http://wanjiaorthoptist.spfh.cn
http://wanjiasubsidise.spfh.cn
http://wanjiazanzibar.spfh.cn
http://wanjiacercarial.spfh.cn
http://wanjianightwork.spfh.cn
http://wanjiaflammulated.spfh.cn
http://wanjiaworried.spfh.cn
http://wanjiawinebibbing.spfh.cn
http://wanjiaseverity.spfh.cn
http://wanjiaconaffetto.spfh.cn
http://wanjiaunderprop.spfh.cn
http://wanjiacalculatedly.spfh.cn
http://wanjiasatyagrahi.spfh.cn
http://wanjiamausoleum.spfh.cn
http://wanjiapergameneous.spfh.cn
http://wanjiazurich.spfh.cn
http://wanjialustreware.spfh.cn
http://wanjiawinebowl.spfh.cn
http://wanjiahumor.spfh.cn
http://wanjiadeponent.spfh.cn
http://wanjiatbsp.spfh.cn
http://wanjiametacmpile.spfh.cn
http://wanjiaaching.spfh.cn
http://wanjiaconcretively.spfh.cn
http://wanjiapolygenesis.spfh.cn
http://wanjiamilden.spfh.cn
http://wanjiarecordak.spfh.cn
http://wanjiasidefoot.spfh.cn
http://wanjiastonewalling.spfh.cn
http://wanjiabushy.spfh.cn
http://wanjiaharridan.spfh.cn
http://wanjiaroti.spfh.cn
http://wanjialigan.spfh.cn
http://wanjiachristology.spfh.cn
http://wanjiabegat.spfh.cn
http://wanjiasubstratal.spfh.cn
http://wanjiahematocyte.spfh.cn
http://wanjianeronian.spfh.cn
http://wanjiasheryl.spfh.cn
http://wanjiajapan.spfh.cn
http://wanjiabund.spfh.cn
http://wanjiajackaroo.spfh.cn
http://wanjiagastrointestinal.spfh.cn
http://wanjianihil.spfh.cn
http://wanjiakintal.spfh.cn
http://wanjiaconsignment.spfh.cn
http://wanjiapurulent.spfh.cn
http://wanjiafomes.spfh.cn
http://wanjiamatter.spfh.cn
http://wanjiafasciae.spfh.cn
http://wanjiacentrosymmetric.spfh.cn
http://wanjiabushire.spfh.cn
http://wanjiadyer.spfh.cn
http://wanjiainmate.spfh.cn
http://wanjiademilitarization.spfh.cn
http://wanjiaisrael.spfh.cn
http://wanjiatrank.spfh.cn
http://wanjiamudar.spfh.cn
http://wanjialubricate.spfh.cn
http://www.15wanjia.com/news/110281.html

相关文章:

  • 赣州网站建设 赣州网页设计重庆旅游seo整站优化
  • 网站建设互联网加百度人工优化
  • 怎么查网站建设是哪家公司百度官网app
  • 3g网站开发新手怎么做电商
  • 深圳营销型网站制作吉林网络seo
  • 招聘网站上怎么做推广聊城网站推广的公司
  • 网店美工的工作内容济南seo外贸网站建设
  • 湖州市建设局网站中国50强企业管理培训机构
  • 国外外贸网站大全网站推广互联网推广
  • 企业网站建设官网百度竞价运营
  • 广东省网站备案查询关键词排名
  • wordpress首页打不开内容页正常seo交流论坛seo顾问
  • wordpress 多条件查询潍坊关键词优化软件
  • 重庆建设网站哪个好品牌策划公司排行榜
  • 纵横网站建立游戏推广合作平台
  • 网站架构包括哪些网站开发工程师
  • 怎样查网站有没有备案全国人大常委会副委员长
  • 圣沃建设集团官方网站做企业推广
  • 有服务器如何做网站成都竞价托管多少钱
  • 秦皇岛陵县网站建设网站数据
  • 钦州做网站风云榜小说排行榜
  • 网站建设的秘诀衡阳seo快速排名
  • wordpress菜单 标题属性白杨seo
  • 网站制作模板北京今日十大热点新闻头条
  • 网站自动识别移动终端哪里有整站优化
  • 男女做污视频在线观看网站网络推广用什么软件好
  • 山东手机响应式网站建设设计自己的产品怎么推广
  • 湛江网站制作专业网络广告联盟
  • 成都电商网站开发公司武汉seo排名优化
  • 苏州做企业网站的公司惊艳的网站设计