intelligenthack / intelligentcache

A distributed cache backed by Redis
MIT License
18 stars 2 forks source link

Support serving stale content, while the cache entry is being refreshed #4

Open aaubry opened 3 years ago

aaubry commented 3 years ago

When a cache entry expires, any subsequent access to it is considered a miss, causing the value to be fetched from the next cache level, or even recomputed. While this is happening, the caller has to wait for the fresh value. If the cache entry is accessed frequently, this means that accesses happening just after an entry has expired will be penalized.

In order to avoid that, we could keep serving the expired content for a short period of time while the content is refreshed in the background. This would prevent the callers from being blocked in many cases.