日期:2014-05-17 浏览次数:20438 次
public static List<Group_User> GetGroupByUid(int Uid)
{
Group_UserBLL bll = new Group_UserBLL();
string key = "groupuser_by_uid" + Uid;//KEY值是如何设置?如何方法GetGroupByUid(int A,int B)传入的参数是2个,key值是怎么的?
List<Group_User> data = (List<Group_User>)HttpRuntime.Cache[key];
// 检查缓存
if (data == null)
{
//如果数据不存在缓存中,则重新读取数据库
data = bll.GetGroupUid(Uid);
try
{
AggregateCacheDependency cd = TableDependency();//这句话建立缓存依赖项有什么作用
//将数据写入缓存
HttpRuntime.Cache.Insert(key, data, cd, DateTime.Now.AddHours(Timeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
}
catch (Exception ex)
{
ex.ToString();
}
}
return data;
}