Tag: 数据缓存

System.Web.Caching.Cache在模型中抛出nullexception

也许这个问题应该很简单,但事实并非如此。 我在ASP.NET中阅读了使用System.Web.Caching.Cache类的问题 。 我有一个单身人士class: private System.Web.Caching.Cache _cache; private static CacheModel _instance = null; private CacheModel() { _cache = new Cache(); } public static CacheModel Instance { get { return _instance ?? new CacheModel(); } } public void SetCache(string key, object value){ _cache.Insert(key, value); } 如果,在我的代码中的任何其他位置,我调用以下内容: CacheModel aCache = CacheModel.Instance; aCache.SetCache(“mykey”, new string[2]{“Val1”, “Val2”}); //this line […]