Is it good practice to set the expiration date of all keys in redis

I am using redis for caching in one of my applications, I need to store about 500,000 keys per day and need to set EXPIRE for all keys. In 5 days I will have about 2.5 million keys and have installed EXPIRE for all keys. Is it fine to set EXPIRE on keys and allow revalidation every minute to find out keys that have expired ( As per the documentation ). How much will this affect performance?

Is there a better alternative for this?

I tried googling but found nothing about performance. My main concern is performance as well as memory.

PS. My redis is currently ending due to too many keys on my redis server.

+3


source to share


1 answer


The usage ends up as a replacement algorithm is not always a good idea that works like a FIFO.

The answer depends on your workload.

If your workload is completely random (no key is available more frequently than others), the replacement algorithm does not work well (so choose a simpler one).



If the older keys are less available than the latest ones, the FIFO is fine.

If some keys are accessed more often (i.e. there are hotkeys), lru is better. See Using Redis as an LRU Cache .

0


source







All Articles