What is the principle of redis expiration?

set a key-value pair in redis and expire after 1000 seconds

set test "nnn"

expire test 1000
After

, change the system time to this time tomorrow, using the following command:

ttl test
-2
The result of

is-2.

excuse me: what is the impact of modifying system time on redis cache?

Mar.11,2021

redis triggers expiration conditions. There are two types:

  • internally query expired key based on system time
  • when actively querying this key, it will detect whether it has expired

redis expiration time is the timestamp after the current time + expiration time is settled, that is, the expiration time. Therefore, the change of system time will affect the expiration time of redis.


official documentation: https://redis.io/commands/exp.


 //client.set24client.set
 client.set(args, data, 'EX', 24 * 60 * 60, (error, param) => {
  });

 client.del(args, args);//client.del

redis official documentation is available.

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-1e9495d-14eb.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-1e9495d-14eb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?