keys pattern 查询相应的key
在redis里,允许模糊查询key
有3个通配符 *, ? ,[]
*: 通配任意多个字符
?: 通配单个字符
[]: 通配括号内的某1个字符
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*
- “one”
redis 127.0.0.1:6379> key *o
(error) ERR unknown command ‘key’
redis 127.0.0.1:6379> keys *o
- “two”
redis 127.0.0.1:6379> keys ???
-
“one”
-
“two”
redis 127.0.0.1:6379> keys on?
- “one”
redis 127.0.0.1:6379> set ons yes
OK
redis 127.0.0.1:6379> keys on[eaw]
- “one”