I am looking for an elegant way of caching the results of my asynchronous operations.
I first had a synchronous method like this:
public String GetSt
It's actually reasonable (and depending on your design and performance, crucial) to keep those failed tasks as a Negative Cache. Otherwise, if a url
always fails, using it again and again defeats the point of using a cache altogether.
What you do need is a way to clear the cache from time to time. The simplest way is to have a timer that replaces the ConcurrentDictionarry
instance. The more robust solution is to build your own LruDictionary
or something similar.