-
扩展命令
172.17.0.2:6379> lpushx mylist x (integer) 6 172.17.0.2:6379> lrange mylist 0 -1 1) "x" 2) "2" 3) "1" 4) "c" 5) "b" 6) "a" 172.17.0.2:6379> lpushx mylist3 x (integer) 0 172.17.0.2:6379> rpushx mylist2 y (integer) 6 172.17.0.2:6379> lrange mylist2 0 -1 1) "a" 2) "b" 3) "c" 4) "1" 5) "2" 6) "y"
172.17.0.2:6379> lpush mylist3 1 2 3 (integer) 3 172.17.0.2:6379> lpush mylist3 1 2 3 (integer) 6 172.17.0.2:6379> lpush mylist3 1 2 3 (integer) 9 172.17.0.2:6379> lrange mylist3 0 -1 1) "3" 2) "2" 3) "1" 4) "3" 5) "2" 6) "1" 7) "3" 8) "2" 9) "1" 172.17.0.2:6379> lrem mylist3 2 3 (integer) 2 172.17.0.2:6379> lrange mylist3 0 -1 1) "2" 2) "1" 3) "2" 4) "1" 5) "3" 6) "2" 7) "1" 172.17.0.2:6379> lrem mylist3 -2 1 (integer) 2 172.17.0.2:6379> lrange mylist3 0 -1 1) "2" 2) "1" 3) "2" 4) "3" 5) "2" 172.17.0.2:6379> lrem mylist3 0 2 (integer) 3 172.17.0.2:6379> lrange mylist3 0 -1 1) "1" 2) "3"
172.17.0.2:6379> lset mylist 3 mmm OK 172.17.0.2:6379> lrange mylist 0 -1 1) "x" 2) "2" 3) "1" 4) "mmm" 5) "b" 6) "a" 172.17.0.2:6379> lpush mylist4 a b c (integer) 3 172.17.0.2:6379> lpush mylist4 a b c (integer) 6 172.17.0.2:6379> lrange mylist4 0 -1 1) "c" 2) "b" 3) "a" 4) "c" 5) "b" 6) "a" 172.17.0.2:6379> linsert mylist4 before b 11 (integer) 7 172.17.0.2:6379> lrange mylist4 0 -1 1) "c" 2) "11" 3) "b" 4) "a" 5) "c" 6) "b" 7) "a" 172.17.0.2:6379> linsert mylist4 after b 22 (integer) 8 172.17.0.2:6379> lrange mylist4 0 -1 1) "c" 2) "11" 3) "b" 4) "22" 5) "a" 6) "c" 7) "b" 8) "a"
172.17.0.2:6379> lpush mylist5 1 2 3 (integer) 3 172.17.0.2:6379> lpush mylist6 a b c (integer) 3 172.17.0.2:6379> lrange mylist5 0 -1 1) "3" 2) "2" 3) "1" 172.17.0.2:6379> lrange mylist6 0 -1 1) "c" 2) "b" 3) "a" 172.17.0.2:6379> rpoplpush mylist5 mylist6 "1" 172.17.0.2:6379> lrange mylist5 0 -1 1) "3" 2) "2" 172.17.0.2:6379> lrange mylist6 0 -1 1) "1" 2) "c" 3) "b" 4) "a"
查看全部 -
获取列表元素个数
172.17.0.2:6379> llen mylist (integer) 5 172.17.0.2:6379> llen mylist2 (integer) 5 172.17.0.2:6379> llen mylist3 (integer) 0
查看全部 -
两端弹出
172.17.0.2:6379> lpop mylist "3" 172.17.0.2:6379> lrange mylist 0 -1 1) "2" 2) "1" 3) "c" 4) "b" 5) "a" 172.17.0.2:6379> rpop mylist2 "3" 172.17.0.2:6379> lrange mylist2 0 -1 1) "a" 2) "b" 3) "c" 4) "1" 5) "2"
查看全部 -
查看列表
172.17.0.2:6379> lrange mylist 0 5 1) "3" 2) "2" 3) "1" 4) "c" 5) "b" 6) "a" 172.17.0.2:6379> lrange mylist 0 -1 1) "3" 2) "2" 3) "1" 4) "c" 5) "b" 6) "a" 172.17.0.2:6379> lrange mylist2 0 -1 1) "a" 2) "b" 3) "c" 4) "1" 5) "2" 6) "3" 172.17.0.2:6379> lrange mylist2 0 -2 1) "a" 2) "b" 3) "c" 4) "1" 5) "2"
查看全部 -
两端添加
172.17.0.2:6379> lpush mylist a b c (integer) 3 172.17.0.2:6379> lpush mylist 1 2 3 (integer) 6 172.17.0.2:6379> rpush mylist2 a b c (integer) 3 172.17.0.2:6379> rpush mylist2 1 2 3 (integer) 6
查看全部 -
Redis 的数据结构
存储 list 常用命令:
两端添加
查看列表
两端弹出
获取列表元素个数
扩展命令
查看全部 -
Redis 的数据结构
存储 list:
ArrayList 使用数组方式
LinkedList 使用双向链接方式
双向链表中增加数据
双向链表中删除数据
查看全部 -
自学命令
172.17.0.2:6379> hexists myhash username (integer) 1 172.17.0.2:6379> hexists myhash password (integer) 0 172.17.0.2:6379> hgetall myhash 1) "username" 2) "jack" 3) "age" 4) "23" 172.17.0.2:6379> hlen myhash (integer) 2 172.17.0.2:6379> hkeys myhash 1) "username" 2) "age" 172.17.0.2:6379> hvals myhash 1) "jack" 2) "23"
查看全部 -
增加数字
172.17.0.2:6379> hincrby myhash age 5 (integer) 23 172.17.0.2:6379> hget myhash age "23"
查看全部 -
删除
172.17.0.2:6379> hdel myhash2 username age (integer) 2 172.17.0.2:6379> hgetall myhash2 (empty array) 172.17.0.2:6379> hdel myhash2 username (integer) 0 172.17.0.2:6379> hmset myhash2 username rose age 21 OK 172.17.0.2:6379> del myhash2 (integer) 1 172.17.0.2:6379> hget myhash2 username (nil)
查看全部 -
取值
172.17.0.2:6379> hget myhash username "jack" 172.17.0.2:6379> hmget myhash username age 1) "jack" 2) "18" 172.17.0.2:6379> hgetall myhash 1) "username" 2) "jack" 3) "age" 4) "18"
查看全部 -
赋值
172.17.0.2:6379> hset myhash username jack (integer) 1 172.17.0.2:6379> hset myhash age 18 (integer) 1 172.17.0.2:6379> hmset myhash2 username rose age 21 OK
查看全部 -
Redis 的数据结构
存储 Hash 常用命令:
赋值
取值
删除
增加数字
自学命令
查看全部 -
Redis 的数据结构
存储 Hash
String Key 和 String Value 的 map 容器
每一个 Hash 可以存储 4294967295 个键值对
查看全部 -
扩展命令
> incrby num 5 (integer) 6 > incrby num3 5 (integer) 5 > decrby num 3 (integer) 3 > decrby num4 3 (integer) -3 > append num 5 (integer) 2 > get num "35" > append num5 123 (integer) 3 > get num5 "123"
查看全部
举报
0/150
提交
取消