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

  • 相关阅读:
    Unity3D脚本修改默认编码界面
    Winform异步初始化UserControl的问题
    Windows API实现移动窗体
    BackgroundWorder控件
    Winform复杂界面异步加载
    TabControl设置选项卡的大小
    VS2010尝试运行项目时出错,无法启动程序
    winform开发-CheckedListBox控件
    tomcat配置https访问
    用户svn密码自定义
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3397483.html
Copyright © 2011-2022 走看看