I have problem with cache in my asp.net mvc3 application.
My code
using System.Web.Caching;
...
class RegularCacheProvider : ICacheProvider
{
Cache cache ;
public object Get(string name)
{
return cache[name];
}
public void Set(string name, object value)
{
cache.Insert(name, value);
}
public void Unset(string name)
{
cache.Remove(name);
}
}
And I use singleton for give value for it :
School schoolSettings = (School)CacheProviderFactory.Cache.Get("SchoolSettings");
if (schoolSettings == null)
{
CacheProviderFactory.Cache.Set("SchoolSettings", someObject);
}
So in first use it does not work and give me an error cache[name] is null.
What I'm doing wrong?
Any help would be appreciated.
cacheat some point? 'cos you haven't.cacheis a singleton and that there is aCacheProviderFactory.Cache- neither of these things are shown in the code. You are asking us to guess what you have removed; that will not lead to a good answer...