1
Basically, I'm trying to figure out what kind of caching mechanism is best (and easiest) for a asp.net MVC5 solution. In previous synchronious solutions, I have used a static dictionary,and the lock keyword when accessing it.
private static Dictionary<string, object> _cache;
private static object _cacheLocker = new object();
private object GetFromCache(string key)
{
return _cache[key];
}
private void AddToCache(string key, object value)
{
lock (_cacheLocker)
{
_cache.Add(key, value);
}
}
But I think there must be a more elegant way of doing this in an async world.
2
What should I cache in an async method? Only the values or the values wrapped inside a Task
Thank you.