Skip to content

Instantly share code, notes, and snippets.

@grumpydev
Forked from thecodejunkie/DefaultViewCache.cs
Created June 7, 2011 09:17
Show Gist options
  • Save grumpydev/1011940 to your computer and use it in GitHub Desktop.
Save grumpydev/1011940 to your computer and use it in GitHub Desktop.
public class DefaultViewCache : IViewCache
{
private readonly ConcurrentDictionary<ViewLocationResult, object> cache;
public DefaultViewCache()
{
this.cache = new ConcurrentDictionary<ViewLocationResult, object>();
}
public TCompiledView GetOrAdd<TCompiledView>(string viewLocationResult, Func<string, TCompiledView> valueFactory)
{
return (TCompiledView)this.cache.GetOrAdd(viewLocationResult, (k) => valueFactory(k));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment