Redis Pttl 命令

更新时间: 2019-07-07 15:54

Redis Pttl 命令以毫秒为单位返回 key 的剩余过期时间。

语法

redis 127.0.0.1:6379> PTTL KEY_NAME

返回值

当 key 不存在时,返回 -2 。 当 key 存在但没有设置剩余生存时间时,返回 -1 。 否则,以毫秒为单位,返回 key 的剩余生存时间。

实例

实例1:当 key 存在,且有设置过期时间时

127.0.0.1:6379> setex domain 120 www.codercto.com
OK
127.0.0.1:6379> pttl domain
(integer) 114363

实例2:当 key 存在,但没有设置过期时间时

127.0.0.1:6379> set domain www.codercto.com
OK
127.0.0.1:6379> pttl domain
(integer) -1

实例3:当 key 不存在时

127.0.0.1:6379> exists domain
(integer) 0
127.0.0.1:6379> pttl domain
(integer) -2

查看更多 Redis key 命令

BSD Hacks

BSD Hacks

Dru Lavigne / O'Reilly Media, Inc. / 2004-05-24 / USD 24.95

If you want more than your average BSD user--you want to explore and experiment, unearth shortcuts, create useful tools, and come up with fun things to try on your own--BSD Hacks is a must-have. This ......一起来看看 《BSD Hacks》 这本书的介绍吧!

HTML 压缩/解压工具

HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具

JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具

RGB转16进制工具

RGB HEX 互转工具