1.设置key值

set name zhangsan

删除key

del name

Redis 键命令

 

2. 判断key是否存在

exists a,返回1 说明存在;  0 表示不存在

Redis 键命令

 

3. 剩余过期时间 ttl(time to leave)

Redis 键命令

返回-1,说明没有过期时间

 

4. 设置key过期时间

expire a 20    过期时间设置为20秒

Redis 键命令

 

-2 说明不存在key了

 

5. type命令

Redis 键命令

代表key的类型为string

 设置可以hash

Redis 键命令

类型hash是hash

 

6. randomkey 随机key,每次key都是随机的

Redis 键命令

 

7 rename重命名key

Redis 键命令

 renamenx 如果已经存在key,在rename失败。

Redis 键命令

 

相关文章:

  • 2021-11-18
  • 2022-02-23
  • 2021-07-14
  • 2021-12-05
  • 2022-01-09
  • 2021-04-24
  • 2022-01-21
猜你喜欢
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2021-12-14
  • 2021-10-21
  • 2021-05-08
  • 2022-12-23
相关资源
相似解决方案