Open geek197 opened 6 years ago
Hi @marcinot Yeah this is not a problem, it is the intended behavior.
Imagine you have an in-memory cache with 1 second absolute expiration and memcached with 10 seconds absolute.
You Add
a key to the cache and read it back via Get
after 5 seconds.
That Get
operation would put it into local in-memory cache with 1 second expiration.
Using the initial created date (5 seconds ago) would mark the item expired right away...
In general, the absolute expiration of an item should start the moment it gets added to a cache handle.
Meaning, if both layers have 10 second absolute expiration and the Get
operation adds the item to the in-memory layer after 5 seconds. The total life time of the cached item would be ~15 seconds.
So, if you have the same absolute expiration on both cache layers, yeah, you'll see that behavior that you might have stale data in memory although the item doesn't exist anymore on the memcached server.
But that could totally be a valid use case, too!
For the use case you have, you should probably use a way lower expiration timeout for the in-memory cache. Like 10 seconds, and 10 minutes out of process. In that scenario, you might still have stale data eventually, but only for a few seconds.
Thank you for fast response :-) I understand your motivation for introducing this change, but my bussines cases are liitle different.
Maybe the simplest solution would be to introduce new expiration mode StrictAbsolute in which CreatedUtc isn't modified.
Hi
I found some problem with CacheManager connected with issue https://github.com/MichaCo/CacheManager/issues/136 (IsExpired not working after extending absolute expiration) and commit https://github.com/MichaCo/CacheManager/commit/fb7ce8e4cb2c99e22f275a98197c93f691c17cc5
This change introduced very strange and unexpected behaviour when I working with multiple application instances using 2-handle cache.
Test scenario:
Conditions:
Time line
This behaviour is completely unexpected - we want to expire item after 10 minutes (from Put), not after 15 or 20 minutes.