Latest web development tutorials

Redis comando TTL

Redis clave (key)

Redis comando TTL devuelve la clave en segundos el tiempo de caducidad restantes.

gramática

redis TTL sintaxis del comando básico es el siguiente:

redis 127.0.0.1:6379> TTL KEY_NAME

versiones disponibles

> = 1.0.0

Valor de retorno

Cuando no existe la clave, devuelve -2. Cuando la llave está presente, pero no establece el tiempo de vida restante, devuelve -1. De lo contrario, el tiempo de supervivencia restante, en milisegundos, la tecla de retorno.

Nota: 2.8 Redis atrás, cuando la clave no existe o no está configurado tiempo de vida restante clave, el comando devuelve -1.

Ejemplos

# 不存在的 key

redis> FLUSHDB
OK

redis> TTL key
(integer) -2


# key 存在,但没有设置剩余生存时间

redis> SET key value
OK

redis> TTL key
(integer) -1


# 有剩余生存时间的 key

redis> EXPIRE key 10086
(integer) 1

redis> TTL key
(integer) 10084

Redis clave (key)