keys * 显示所有key
查找所有以s开头的key
用s* *代表任意字符
127.0.0.1:6379> keys s* 1) "set3" 2) "sort1" 3) "set2" 4) "set1" 127.0.0.1:6379> keys s*1 1) "sort1" 2) "set1"
查找所有s开头 后面紧跟任意一个字符的key
127.0.0.1:6379> keys s? 1) "s1"
del删除key
exists判断key是否存在 1表示存在 0表示不存在
127.0.0.1:6379> exists s1 (integer) 1 127.0.0.1:6379> exists asdasd (integer) 0
get获取元素
127.0.0.1:6379> lrange list1 0 -1 1) "b" 2) "a" 127.0.0.1:6379> get list1 (error) WRONGTYPE Operation against a key holding the wrong kind of value 127.0.0.1:6379> get s1 "123456"
rename对key重命名
127.0.0.1:6379> get s1 "123456" 127.0.0.1:6379> rename s1 s1_new OK 127.0.0.1:6379> get s1_new "123456" 127.0.0.1:6379> get s1 (nil)
expire 设置n2 有效时间
ttl查看剩余时间
127.0.0.1:6379> expire s1_new 120 (integer) 1 127.0.0.1:6379> ttl s1_new (integer) 113
type显示类型
127.0.0.1:6379> type name string 127.0.0.1:6379> type list2 list 127.0.0.1:6379> type set3 set 127.0.0.1:6379> type sort1 zset 127.0.0.1:6379> type r1 set 127.0.0.1:6379> type student hash