Redis-Learn about the return value of the TTL command

Basic grammar

TTL  key

TTL命令用来查询一个键还有多久的时间会被删除。

The key has an expiration time set, and then the key is deleted or expired, use the return value of the TTL command

Operation example:
Insert picture description here

The key does not set the expiration time, use the return value of the TTL command

Operation example:
Insert picture description here
If the key has an expiration time set, when the key expires or is deleted, the TTL command returns -2. When the key does not set an expiration time, it means it is permanent, and the TTL command returns -1.

Guess you like

Origin blog.csdn.net/weixin_38106322/article/details/108500498