zoukankan      html  css  js  c++  java
  • 设置缓存

    先定义一个缓存变量

     int cacheMinute = int.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["ModelCache"]);       //缓存时间(分钟)

     

    在需要设置缓存的上边写红色代码

                string cacheKey = "kdp-newPro-" + pNum;             object objCache = clsUtility.GetCache(cacheKey);

               if (objCache == null)             {                 string sort = "";                 string strWhere = " where 1=1 and commlist.CTime>DateAdd(d,-20,getdate()) and vw.id1 in (1,2,3) ";                 string strSql = @"select top 740 row_number() over(order by commlist.ID) as r_n,commlist.p_name,commlist.pid,commlist.cur_price                                     from Da_CommodityList commlist                                      left join vw_Grading vw on commlist.catid=vw.id4 " + strWhere;                 //分页                 dt1 = sys.GetRecordByPage(strSql, pNum, pSize, sort, out rCount, out pCount).Tables[0];                 clsUtility.AddCache(cacheKey, dt1, cacheMinute);             }             else             {                 dt1 = objCache as DataTable;             }             cacheKey = "kdp-newPro-rCount" + pNum;             objCache = clsUtility.GetCache(cacheKey);             if (objCache == null)             {                 clsUtility.AddCache(cacheKey, rCount, cacheMinute);             }             else             {                 rCount = int.Parse(objCache.ToString());       //八分页进行缓存,否则不会显示页码             }             repNewPro.DataSource = dt1;             repNewPro.DataBind();

  • 相关阅读:
    swift优秀学习博客
    Swift主题色顶级解决方案一
    如何用 Swift 语言构建一个自定控件
    自定义UISlider的样式和滑块
    让你提前知道软件开发(27):创建数据库表和索引
    [6] 算法路
    OGG "Loading data from file to Replicat"table静态数据同步配置过程
    一些书籍和下载链接地址读研究生
    悖论软件测试农药
    Maven直接部署Web应用Tomcat
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3397483.html
Copyright © 2011-2022 走看看