Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Azure Redis Cache flushes items when expiration hit

I have a scenario where I plan to set the Azure Redis Cache entry expiration time to ensure we don't keep data that is known to be of no value after a specific point in time, e.g.

cache.StringSet(this.cacheId, this.Serialize(), expiry);

Also, the intent would be to keep the Redis cache performance from in any way being impacted by containing more entries than those that are actually of use.

Does Azure Redis flushes entries as when they have hit a defined expiration time or does it only do that when pressured to reduce in memory footprint and backend persistent storage?

like image 609
myusrn Avatar asked Jan 31 '16 05:01

myusrn


1 Answers

Azure Redis uses standard Redis behavior around expiration, see the Redis Documentation for details. Here is a quote from that page...

How Redis expires keys

Redis keys are expired in two ways: a passive way, and an active way. A key is actively expired simply when some client tries to access it, and the key is found to be timed out.

Of course this is not enough as there are expired keys that will never be accessed again. These keys should be expired anyway, so periodically Redis tests a few keys at random among keys with an expire set. All the keys that are already expired are deleted from the keyspace.

like image 171
JonCole Avatar answered Oct 04 '22 17:10

JonCole