三、Redis通用命令

                     Redis通用命令

1、keys命令


keys [pattern] //遍历查询所有满足条件的key

keys *         //列出所有的key

keys he*       //he开头的key

keys he[a-d]*  //第三位是a-d范围内的

keys he?      //key长度为3,第三位任意字母

2、dbsize

计算所有key的数量,通过计数器返回key数量值。

3、获取、删除、判断是否存在

del key      //删除key

exists key   //判断key是否存在

get  key     //获取key对应的value

4、expire、ttl、persist

expire key seconds   //设置key在多少秒后过期

ttl key             //查询key剩余的过期时间

persist key         //使key没有过期时间,一直存在

5、type

type key    //返回key对应value的类型

返回值:string 、hash、list、set、zset、none(不存在)

猜你喜欢

转载自blog.csdn.net/newbie_907486852/article/details/81611977