Redis TTL 命令

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

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

语法

redis 127.0.0.1:6379> TTL KEY_NAME

返回值

  • 当 key 不存在时,返回 -2 。

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

实例

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

127.0.0.1:6379> get domain
"www.codercto.com"
127.0.0.1:6379> ttl domain
(integer) -1

实例2: 当 key 不存在

127.0.0.1:6379> exists domain2
(integer) 0
127.0.0.1:6379> ttl domain2
(integer) -2

实例3: 当 key 存在且设置了过期时间

127.0.0.1:6379> exists domain
(integer) 1
127.0.0.1:6379> EXPIRE domain 60
(integer) 1
127.0.0.1:6379> ttl domain
(integer) 57

查看更多 Redis key 命令

The Intersectional Internet

The Intersectional Internet

Safiya Umoja Noble、Brendesha M. Tynes / Peter Lang Publishing / 2016

From race, sex, class, and culture, the multidisciplinary field of Internet studies needs theoretical and methodological approaches that allow us to question the organization of social relations that ......一起来看看 《The Intersectional Internet》 这本书的介绍吧!

HTML 编码/解码

HTML 编码/解码

HTML 编码/解码

UNIX 时间戳转换

UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具

HSV CMYK 转换工具

HSV CMYK互换工具