public void pro_ShowBook_tw(HttpContext context)
{

DataTable dt = null;
string cacheKey = "GetList";   ///唯一的key值
if (HttpContext.Current.Cache[cacheKey] == null) ///是否存在
{
dt = BLL.BLL_Activity2019.pro_ShowBook_tw();  ///不存在,查询数据
if (dt.Rows.Count > 0)
{
HttpContext.Current.Cache.Insert(cacheKey, dt, null, DateTime.Now.AddMinutes(10), System.Web.Caching.Cache.NoSlidingExpiration);//  缓存10分钟
}

}
else
{
dt = (DataTable)HttpContext.Current.Cache[cacheKey];  ///存在查询缓存
}


string result = JsonConvert.SerializeObject(new{data = new { list = dt }});转换成json


context.Response.Write(result);

}

相关文章:

  • 2021-11-15
  • 2021-11-14
  • 2021-06-07
  • 2021-08-27
  • 2022-12-23
  • 2021-09-24
猜你喜欢
  • 2022-12-23
  • 2021-07-08
  • 2022-01-15
  • 2021-08-17
  • 2021-08-06
相关资源
相似解决方案