public static void RefreshData(String key, Object item, CacheItemRemovedReason reason) { try { lock (_cache) { BusinessLogic.Parameter.Parameter par = new BusinessLogic.Parameter.Parameter(); DataSet.DSParameter ds = par.GetParamerter(); System.TimeSpan span = new TimeSpan(0, 0, 30, 20, 0); //if( ds != null ) // _cache["data"] = ds; _cache.Insert("data", ds, null, Cache.NoAbsoluteExpiration, span, CacheItemPriority.High, new CacheItemRemovedCallback(RefreshData)); } } catch { } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); _cache = Context.Cache; BusinessLogic.Parameter.Parameter par = new BusinessLogic.Parameter.Parameter(); DataSet.DSParameter ds = par.GetParamerter(); System.TimeSpan span = new TimeSpan(0, 0, 2, 20, 0); _cache.Insert("data", ds, null, Cache.NoAbsoluteExpiration, span, CacheItemPriority.Default, new CacheItemRemovedCallback(RefreshData)); }
protected void UpdateCache() { BusinessLogic.Parameter.Parameter par = new BusinessLogic.Parameter.Parameter(); DataSet.DSParameter ds = par.GetParamerter(); if (ds != null) { lock ( MvcApplication._cache ) { MvcApplication._cache["data"] = ds; } } }