/// <summary> /// Func /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <param name="func"></param> /// <returns></returns> public static T GetDate <T> (string key, Func <T> func, int minute) { T result = default(T); if (CustomCache.Contains(key)) { result = CustomCache.Get <T>(key); } else { result = func.Invoke();//DataSource.Count(key); CustomCache.Add(key, result, minute); } return(result); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key">key</param> /// <param name="func">委托</param> /// <returns></returns> public static T CachGet <T>(string key, Func <T> func) { T result = default(T);//准备一个结果集 if (CustomCache.Exist(key)) { result = CustomCache.Get <T>(key); } else { result = func.Invoke(); CustomCache.Add(key, result); } return(result); }