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 命令

XMPP

XMPP

Peter Saint-Andre、Kevin Smith、Remko TronCon / O'Reilly Media / 2009-5-4 / USD 39.99

This practical book provides everything you need to know about the Extensible Messaging and Presence Protocol (XMPP). This open technology for real-time communication is used in many diverse applicati......一起来看看 《XMPP》 这本书的介绍吧!

CSS 压缩/解压工具

CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器

Markdown 在线编辑器

Markdown 在线编辑器

HEX CMYK 转换工具

HEX CMYK 转换工具

HEX CMYK 互转工具