I am using redis for caching in one of my application,I need to store around 500 000 keys per day & need to set a EXPIRE for all keys. After 5 days I will be have about 2.5 million keys & I have set EXPIRE for all the keys. Is it fine to set EXPIRE for the keys & let the redis scan every minute to find out expire keys (According to the documentation). How much would be the performance impact because of this?
Is there a better alternative for this?
I tried to search on Google,But nothing found about performance. My main concern is performance as well as memory too.
PS. Currently my redis is running out of space because of too much keys on my redis server.
Using expires as the replacement algorithm is not always a good idea, which works like FIFO.
The answer depends on your workload.
If your workload is completely random (no key is accessed more frequent than others), no replacement algorithm works well (so, choose a simpler one).
If older keys are less accessed than recent keys, FIFO is ok.
If some keys are accessed more frequently (i.e., there are hot keys), lru is better. See Using Redis as an LRU cache.