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();

  • 相关阅读:
    cf Inverse the Problem (最小生成树+DFS)
    cf Make It Nondeterministic (简单贪心)
    cf Learn from Life (简单贪心)
    hdu 5057 Argestes and Sequence (数状数组+离线处理)
    hdu 5056 Boring count (类似单调队列的做法。。)
    hdu 5055 Bob and math problem (很简单贪心)
    三样东西能让女人幸福一生
    第01课 OpenGL窗口(4)
    爱情要不要吃回头草?(林忆)
    第01课 OpenGL窗口(3)
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3397483.html
Copyright © 2011-2022 走看看