Home  >  Article  >  Database  >  What is the expiration policy in Redis

What is the expiration policy in Redis

PHPz
PHPzforward
2023-05-28 19:13:271032browse

Expiration strategy of Redis

Redis mainly has two expiration deletion strategies

Lazy deletion

Lazy deletion refers to when we query the key The key is detected only when the expiration time has been reached, and then deleted. Obviously, one of its disadvantages is that if these expired keys are not accessed, they will never be deleted and will continue to occupy memory.

Periodic deletion

Periodic deletion means that redis checks the database every once in a while and deletes the expired keys. Since it is impossible to poll all keys for deletion, redis will randomly select some keys for checking and deletion each time.

The above is the detailed content of What is the expiration policy in Redis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete