关于key常用命令
-
keys * :查看所有的key
-
keys xx?:查看以xx开头的key,?匹配单个字符,*匹配多个字符
-
del :删除key
-
exists:是否存在某个key
-
rename:对某个key重命名
-
expire:设置过期时间,单位秒
-
ttl:查看距离过期时间,如果没设置过期时间,则返回-1
-
type:查看key的类型
jia:0>set myset "jia" "OK" jia:0>hmset user name zhangjia age 22 "OK" jia:0>lpush list 1 2 3 "3" jia:0>sadd my1 a b c "3" jia:0>zadd days 1 a 2 c 3 b "3" jia:0>keys * 1) "my1" 2) "user" 3) "days" 4) "myset" 5) "list" jia:0>rename list mylist "OK" jia:0>keys * 1) "my1" 2) "mylist" 3) "user" 4) "days" 5) "myset" jia:0>keys my? 1) "my1" jia:0>keys my* 1) "my1" 2) "mylist" 3) "myset" jia:0> jia:0>exists jia "0" jia:0>expire user 100 "1" jia:0>ttl user "85" jia:0>type my1 "set" jia:0>type mylist "list" jia:0>type user "hash" jia:0>type days "zset" jia:0>type myset "string"
请登录之后再进行评论