Redis mainly has two expiration deletion strategies
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 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!