I am currently caching the result of a method call.
The caching code follows standard templates: it uses an element in the cache, if it exists, otherwise it calculates the result, caching it for future calls, before returning it.
I would like to protect client code from cache skips (for example, when an item has expired).
I am thinking of creating a thread to wait for the life of the cached object, and then running the provided function to refill the cache when (or only earlier) the existing item expires.
Can anyone share experiences related to this? Does that sound like a reasonable approach?
I am using .NET 4.0.
source
share