通用命令
- 字符串类型
- 哈希类型
- 列表类型
- 集合类型
- 有序集合类型
通用命令:
通用命令
单线程架构
数据结构和内部编码
通用命令
keys 遍历所有的key
dbsize exisits key del key expire key seconds 设置过期 时间 type key 数据类型
api:keys *
遍历所有key
set hello world
set php good
set java best
keys *
java
php
hello
1: keys
mset hello world heh haha php good phe his ok
keys he[h-l]*
"hehe"
"hello"
keys ph?
keys 一般不在生产环境中使用 执行效率比较慢 会堵塞其它线程
keys 热备到从节点
scan
2:dbsize
mset k1 v1 k2 v2 k3 v3 k4 v4
dbsize
4
sadd myset a b c d e
dbsize
3:exists
set a b
exists a
del a
exist a
4:del
del key #删除指定的key-value
set a b
get a
del a
get a
**5:expire ttl persist **
expire key seconds #key 在seconds秒后过期
ttl key #查看key剩余的过期时间
persist key #去掉key的过期时间
set hello world
>>ok
expire hello 20
>>1
ttl hello
>>16
get hello
>>world
ttl hello
>>-2
>set hello world
ok
>expire hello 20
1
>ttl hello
16
>persist hello
1
ttl hello
-1
6:type
- string
- hash
- list
- set
- zset
- none
>set a b
ok
>type a
string
>sadd myset 1 2 3
3
type myset
set
*时间复杂度