求泛型问题答案
有方法如下:
/// <summary>
/// 通用应用程序缓存方法,缓存数据10分钟永不过期
/// </summary>
/// <typeparam name="T">委托getdata的返回值</typeparam>
/// <param name="key">缓存Key</param>
/// <param name="getdata">获取值得基本方法</param>
/// <param name="paramobects">向getdata传递的参数</param>
/// <returns></returns>
public static T GetCache<T>(string key, Func<T> getdata, params object[] paramobects)
{
if (HttpRuntime.Cache[key] == null)
{
T dataList = getdata();
HttpRuntime.Cache.Add(key, dataList, null, Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(10), System.Web.Caching.CacheItemPriority.High, null);
return dataList;
}
return (T)HttpRuntime.Cache[key];
}
<member name="M:DragonUtility.Caching.WebCache.GetCache``1(System.String,System.Func{``0},System.Object[])"><summary> 通用应用程序缓存方法,缓存数据10分钟永不过期 </summary><typeparam name="T">委托getdata的返回值</typeparam><param name="key">缓存Key</param><param name="getdata">获取值得基本方法</param><param name="paramobects">向getdata传递的参数</param><returns/></member>