redis_chapter3_list

127.0.0.1:6379> keys *

(empty list or set)

127.0.0.1:6379> LPUSH list one

(integer) 1

127.0.0.1:6379> LPUSH list two

(integer) 2

127.0.0.1:6379> LPUSH list thtee

(integer) 3

127.0.0.1:6379> LRANGE list

(error) ERR wrong number of argumen

127.0.0.1:6379> LRANGE list 0 -1 // 获取lsit 中的值

1) "thtee"

2) "two"

3) "one"

127.0.0.1:6379> LRANGE list 0 1 // 通过具体区间 获取某些值

1) "thtee"

2) "two"

127.0.0.1:6379> LPUSH list thtee

127.0.0.1:6379> LRANGE list 0 1

1) "thtee"

2) "two"

127.0.0.1:6379> RPUSH list zhang // 将多个值 放到尾部

(integer) 4

127.0.0.1:6379> LRANGE list 0 -1

1) "thtee"

2) "two"

3) "one"

4) "zhang"

127.0.0.1:6379> LRANGE list 0 -1

同样 移除 LPOP RPOP

eg: Lpop list // 移除左边的值

Rpop list // 移除右边的值

################################

Kindex 获取list 的第一个值

lindex list 1 通过下标获取某一个值

lindex list 0

*********************************

Llen list // 返回列表的长度

移除指定值 : 取关某个up主

lrem list 1 one // 移除list 中 1 个 one

lrem list 2 three // 移除list 中 2 个 three

**************

trim 修剪

trim list 1 2 // 截取得到中间两个values值

##############

rpoplpush

rpoplpush list1 list2 // 移除list1的最后一个 到 新的list2 中首位

EXISTS list

0 // list is not exit

lset list 0 item // add item in index 0 to list //需要先判断类编是否存在

ETT no such key

lpush list value1

LRANGE list 0 0

#"values"

lset list 0 item // 吧list index = 0 value set item 将列表中指定下标的值 更换为某个值

#ok

LRANGE list 0 0

#item

#########################

insert

linsert 左插 右插

Rpush mylist "hello"

Rpush mylist "world"

LINSERT mylist before "world" "honggang"

LRAGNE mylist 0 -1

LINSERT mylist after world zhang

LRANGE mylist 0 -1

list infact is a 链表,before Node after,left,right 都可以插入值

若 key 不存在 创建新的链表

在 新增内容

移除所有值 空链表 不存在

两边插入 或者改动 效率最高 中间操作效率低

消息队列(Lpush Rpop) 栈(Lpush Lpop)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值