Redis Expire TTL命令
2024-09-02 12:13:32
Redis can be told that a key should only exist for a certain length of time. This is accomplished with the EXPIRE and TTL commands. SET resource:lock "Redis Demo"
EXPIRE resource:lock 120
This causes the key resource:lock to be deleted in 120 seconds. You can test how long a key will exist with the TTL command. It returns the number of seconds until it will be deleted. TTL resource:lock => 113
// after 113s
TTL resource:lock => -2
The -2 for the TTL of the key means that the key does not exist (anymore). A -1 for the TTL of the key means that it will never expire. Note that if you SET a key, its TTL will be reset. SET resource:lock "Redis Demo 1"
EXPIRE resource:lock 120
TTL resource:lock => 119
SET resource:lock "Redis Demo 2"
TTL resource:lock => -1
EXPIRE: 设置一个key的存活时间
TTL: 查询一个Key的存活时间
最新文章
- In-Memory:内存数据库
- less入门
- 使用antd UI组件有感
- Linux C 字符串输出函数 puts()、fputs()、printf() 详解
- JS 根据特定URL获取ID数组
- ASP.NET获取IP的6种方法 ( 转)
- Java MD5加密工具类
- win7开启硬盘AHCI
- Android,iOS,浏览器打开手机QQ与指定用户聊天界面
- SQL Server2008知识点总结
- iOS注册远程推送消息证书后提示此证书签发者无效的解决办法
- [ubuntu]apt-get update突然出现arm package找不到
- Django model 字段类型及选项解析---转载
- iptables 配置说明
- 死锁排查的小窍门 --使用jdk自带管理工具jstack
- 07 zabbix之map拓扑标签中macro应用
- 【转】Ubuntu FireFox无法播放网页视频音乐的解决办法
- php 带省略号的分页
- Linux fdisk普通分区扩容
- RAPID程序设计