Per Reclaim expired keys memory faster,
You can follow one of these three steps to reclaim the memory:
- Restart your redis-server
- Increase memorysamples in redis conf. (default is 5, max is 10) so that expired keys are reclaimed faster.
- You can set up a cron job that runs the scan command after an interval which helps in reclaiming the memory of the expired keys.
- Alternatively, Increasing the expiry of keys also helps.
As we know, Redis uses a randomized algorithm to find out keys that should be expired, so the second method would increase the probability of expired keys being reclaimed.
The third method the scan method could force a passive removal across all the keyspace
I am confused why the fourth method Increasing the expiry of keys could reclaim expired keys faster? Could someone give me more details?