redis指令集

string 指令类型

127.0.0.1:6379> set a 100
OK
127.0.0.1:6379> get a
"100"
127.0.0.1:6379> incr a
(integer) 101
127.0.0.1:6379> incr a
(integer) 102
127.0.0.1:6379>
root@e693a2c84f9a:/data# redis-cli
127.0.0.1:6379> set title redis
OK
127.0.0.1:6379> type a
string
127.0.0.1:6379> get a
"102"
127.0.0.1:6379> get title
"redis"
127.0.0.1:6379> decr a
(integer) 101
127.0.0.1:6379> decr a
(integer) 100
127.0.0.1:6379> decrby 10
(error) ERR wrong number of arguments for 'decrby' command
127.0.0.1:6379> decrby a 10
(integer) 90
127.0.0.1:6379> apend title 6.3.3
(error) ERR unknown command `apend`, with args beginning with: `title`, `6.3.3`,
127.0.0.1:6379> append title 6.3.3
(integer) 10
127.0.0.1:6379> get title
"redis6.3.3"
127.0.0.1:6379> strlen title
(integer) 10
127.0.0.1:6379> mget a title
1) "90"
2) "redis6.3.3"
127.0.0.1:6379> mset x 100 y 200
OK
127.0.0.1:6379> mget x y
1) "100"
2) "200"
127.0.0.1:6379> 127.0.0.1:6379> set a 100
(error) ERR unknown command `127.0.0.1:6379>`, with args beginning with: `set`, `a`, `100`,
127.0.0.1:6379> set aa dong
OK
127.0.0.1:6379> get aa
"dong"
127.0.0.1:6379> get *
(nil)
127.0.0.1:6379> keys *
1) "y"
2) "username"
3) "x"
4) "title"
5) "a"
6) "aa"
7) "name"

flushdb 清空数据

Hash类型

127.0.0.1:6379> flushdb
OK
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> hset blog id 100
(integer) 1
127.0.0.1:6379> hset blog title hello-redis
(integer) 1
127.0.0.1:6379> hget blog id
"100"
127.0.0.1:6379> hget blog title
"hello-redis"
127.0.0.1:6379> hgettall blog
(error) ERR unknown command `hgettall`, with args beginning with: `blog`,
127.0.0.1:6379> hgetall blog
1) "id"
2) "100"
3) "title"
4) "hello-redis"
127.0.0.1:6379> hincrby blog id 100
(integer) 200
127.0.0.1:6379> hincrby blog id -100
(integer) 100
127.0.0.1:6379> hset blog status 1 views 100
(integer) 2
127.0.0.1:6379> hgetall blog
1) "id"
2) "100"
3) "title"
4) "hello-redis"
5) "status"
6) "1"
7) "views"
8) "100"
127.0.0.1:6379> hmget blog id title status
1) "100"
2) "hello-redis"
3) "1"
127.0.0.1:6379> hexists blog createdTime
(integer) 0
127.0.0.1:6379> hdel blog status
(integer) 1
127.0.0.1:6379> hgetall blog
1) "id"
2) "100"
3) "title"
4) "hello-redis"
5) "views"
6) "100"
127.0.0.1:6379> hkeys blog
1) "id"
2) "title"
3) "views"
127.0.0.1:6379> hvals blog
1) "100"
2) "hello-redis"
3) "100"
127.0.0.1:6379>

进入redis容器的命令

docker exec -it redis01 bash

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值