我可以确定.Method.MethodHandle.GetFunctionPointer()
每个匿名函数都是唯一的吗?想做
public static T Get<T>(Func<T> getDataCallback) where T : class
{
string cacheID = getDataCallback.Method.MethodHandle.GetFunctionPointer().ToString();
var data = HttpRuntime.Cache.Get(cacheID) as T;
if (data == null)
{
data = getDataCallback();
HttpContext.Current.Cache.Insert(cacheID, data);
}
return data;
}