When python sets the expiration time of a key in redis to-1, why is this key destroyed directly?

key_name = "test_h"
redis.expire(key_name, -1)
redis.execute()

This key is destroyed directly in

redis. Why?

Jan.18,2022

The

python function is a wrapper for commands. Look directly at the document examples

redis> SET mykey "Hello"
OK
redis> EXPIRE mykey 10
(integer) 1
redis> TTL mykey
(integer) 10
redis> SET mykey "Hello World"
OK
redis> TTL mykey
(integer) -1
redis> 

you can see that the expiration time when deleting key is-1

look at Normally Redis keys are created without an associated time to live. again The key will simply live forever, unless it is removed by the user in an explicit way
means that if the expiration time is not set, it will never expire


has expired. If it expires, it will be destroyed


if you want it to never expire, use redis.persist (key)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c06a-2bb29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c06a-2bb29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?