What should I do if I want to periodically expire the expiration key of redis?

Alibaba cloud Q & A 2022-02-13 08:31:00 阅读数:687

want periodically expire expiration key

If you want to Redis The expiration key of is used for periodic expiration processing , What to do ?

Take the answer 1:

Every once in a while , Will scan a certain number of databases expires A certain number of in the dictionary key, And remove the expired key. The strategy is a compromise between the first two . By adjusting the time interval of timing scanning and the limited time of each scanning , Can make in different situations CPU And memory resources to achieve the best balance effect . (expires The dictionary will save all the expired key The expiration date of , among ,key Is a pointer to a key in the key space ,value Is the millisecond precision of the key UNIX The expiration time indicated by the time stamp . Bond space refers to the Redis All keys stored in the cluster .)

copyright:author[Alibaba cloud Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130830586172.html