public static bool Remove(string key, SimpleCacheType type) { var cachekey = CreateCacheKey(key, type); var removed = HttpRuntime.Cache.Remove(cachekey); if (removed == null) { return(false); } return(true); }
public static T GetCacheValue <T>(object key, SimpleCacheType cacheType, OnGetCacheValue <T> onGetValue, int timeOut = 9999) { string cacheKey = (int)cacheType + "#_#" + key.ToString(); T result = default(T); try { result = (T)HttpRuntime.Cache[cacheKey]; } catch { result = default(T); } if (result == null && onGetValue != null) { result = onGetValue(); if (result != null) { HttpRuntime.Cache.Insert(cacheKey, result, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(timeOut)); } } return(result); }
public static void Remove(object key, SimpleCacheType cacheType) { string cacheKey = (int)cacheType + "#_#" + key.ToString(); HttpRuntime.Cache.Remove(cacheKey); }
private static string CreateCacheKey(string key, SimpleCacheType type) { return(string.Concat(type, "-", key)); }
public static void Add(string key, object value, SimpleCacheType type) { Add(key, value, type, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 10)); }
public static void Add(string key, object value, SimpleCacheType type, TimeSpan slidingExpiration) { Add(key, value, type, Cache.NoAbsoluteExpiration, slidingExpiration); }
public static void Add(string key, object value, SimpleCacheType type, DateTime absoluteExpiration) { Add(key, value, type, absoluteExpiration, Cache.NoSlidingExpiration); }
private static void Add(string key, object value, SimpleCacheType type, DateTime absoluteExpiration, TimeSpan slidingExpiration) { var cachekey = CreateCacheKey(key, type); HttpRuntime.Cache.Insert(cachekey, value, null, absoluteExpiration, slidingExpiration); }
public static object Get(string key, SimpleCacheType type) { var cachekey = CreateCacheKey(key, type); return(HttpRuntime.Cache.Get(cachekey)); }