redis

对 Key 进行操作的 API

全部清空

1
2
hominsu-redis-docker:0>FLUSHALL
"OK"

清空当前 DB

1
2
hominsu-redis-docker:0>FLUSHDB
"OK"

设置 key

1
2
3
4
hominsu-redis-docker:0>set name hominsu
"OK"
hominsu-redis-docker:0>set age 19
"OK"

查看全部 keys

1
2
3
hominsu-redis-docker:0>keys *
1) "age"
2) "name

判断某个键是否存在

1
2
3
4
hominsu-redis-docker:0>EXISTS nam
"0"
hominsu-redis-docker:0>EXISTS name
"1"

移动到另一个 DB

1
2
hominsu-redis-docker:0>move name 1
"1"

获取 name 的值

1
2
hominsu-redis-docker:0>get name
"hominsu"

设置过期

1
2
3
4
5
6
7
8
hominsu-redis-docker:0>expire name 10
"1"
hominsu-redis-docker:0>ttl name
"6"
hominsu-redis-docker:0>ttl name
"-2"
hominsu-redis-docker:0>get name
null

查看数据类型

1
2
3
4
hominsu-redis-docker:0>type name
"string"
hominsu-redis-docker:0>type name
"string"