public static void ClearCache(string cacheName) { if (!CacheExtensions.CheckCache(cacheName)) { return; } HttpContext.Current.Cache.Remove(cacheName); }
public static T GetCacheWithSet <T>(string cacheName, Func <T> valueFunc) { if (!CacheExtensions.CheckCache(cacheName)) { CacheExtensions.SetCache(cacheName, (object)valueFunc()); } return(CacheExtensions.GetCache <T>(cacheName)); }
public static MvcHtmlString Cache(this HtmlHelper htmlHelper, string cacheName, Func <object> func, CacheTimeType cacheTimeType, int cacheTime) { if (!CacheExtensions.CheckCache(cacheName)) { CacheExtensions.SetCache(cacheName, (object)func().ToString(), cacheTimeType, cacheTime); } return(MvcHtmlString.Create(CacheExtensions.GetCache <string>(cacheName))); }
public static T GetCacheWithSet <T>(string cacheName, Func <T> valueFunc, CacheTimeType cacheTimeType, int times) { if (!CacheExtensions.CheckCache(cacheName)) { CacheExtensions.SetCache(cacheName, (object)valueFunc(), cacheTimeType, times); } return(CacheExtensions.GetCache <T>(cacheName)); }
public static void RestCache(string cacheName, object value) { if (CacheExtensions.CheckCache(cacheName)) { HttpContext.Current.Cache[cacheName] = value; } else { CacheExtensions.SetCache(cacheName, value); } }