1.keys pattern 命令–>获取key值
文中提到redis中允许模糊查询的有3个通配符,分别是:*,?,[]
其中:
*:通配任意多个字符
?:通配单个字符
[]:通配括号内的某一个字符
redis 127.0.0.1:6379> flushdb
OK
redis 127.0.0.1:6379> keys *
(empty list or set)
redis 127.0.0.1:6379> mset one 1 two 2 three 3 four 4
OK
redis 127.0.0.1:6379> keys o*
1) "one"
redis 127.0.0.1:6379> key *o
(error) ERR unknown command 'key'
redis 127.0.0.1:6379> keys *o
1) "two"
redis 127.0.0.1:6379> keys ???
1) "one"
2) "two"
redis 127.0.0.1:6379> keys on?
1) "one"
redis 127.0.0.1:6379> set ons yes
OK
redis 127.0.0.1:6379> keys on[eaw]
1)"one"
2.randomkey–>随机获取key值
127.0.0.1:6379> randomkey
"name"
3.type keyname–>获取某个key中的存储的类型
127.0.0.1:6379> type age
string
4.exists keyname–>判断某个key是否存在
127.0.0.1:6379> exists age
(integer) 1
5.del keyname–>删除某个key值
127.0.0.1:6379> del age
(integer) 1
网友评论