
目录
KEYS
返回所有满⾜样式(pattern)的 key。
返回值:匹配 pattern 的所有 key。
语法

⽀持如下统配样式:
h?llo matches hello, hallo and hxllo
h*llo matches hllo and heeeello
h[ae]llo matches hello and hallo, but not hillo
h[^e]llo matches hallo, hbllo, ... but not hello
h[a-b]llo matches hallo and hbllo
EXISTS
判断某个 key 是否存在。
返回值:key 存在的个数。
语法
举例
DEL
删除指定的 key。
返回值:删除掉的 key 的个数。
语法

举例

EXPIRE
为指定的 key 添加秒级的过期时间(Time To Live TTL)。
返回值:1 表⽰设置成功。0 表⽰设置失败。
语法


举例

TTL
获取指定 key 的过期时间,秒级。
返回值:剩余过期时间。-1 表⽰没有关联过期时间,-2 表⽰ key 不存在。
语法

举例

TYPE
返回 key 对应的数据类型。
返回值: none , string , list , set , zset , hash and stream .。
语法

举例

type 命令实际返回的就是当前键的数据结构类型,它们分别是:string(字符串)、list(列
表)、hash(哈希)、set(集合)、zset(有序集合),但这些只是 Redis 对外的数据结构。
Redis数据结构和内部编码
