zoukankan      html  css  js  c++  java
  • 网页 缓存

    掉用缓存方法:

     var listModel =ProclamationCache.GetProclamationList();

    //实现方法

    public static List<ProclamationModel> GetProclamationList()
    {
    var cache = GetTopProclamationList();
    if (cache != null)
    {
    return cache;
    }
    return null;
    }

    //实现调用方法

    private static List<ProclamationModel> GetTopProclamationList()
    {
    string CacheKey_ProList = "_CacheKey_ProList";
    int CacheOutTime = ConfigHelperBLL.CacheOutTime;

    List<ProclamationModel> listModel = HttpRuntime.Cache[CacheKey_ProList] as List<ProclamationModel>;
    if (listModel == null)
    {
    listModel = GetProclamationList_ForCache(0, 30);
    HttpRuntime.Cache.Insert(CacheKey_ProList, listModel, null,
    DateTime.Now.AddSeconds(CacheOutTime), System.Web.Caching.Cache.NoSlidingExpiration, GetTopProclamationList_UpdateCallback);
    }
    return listModel;
    }

    //实现调用方法

    private static void GetTopProclamationList_UpdateCallback(string key, CacheItemUpdateReason reason, out object expensiveObject, out CacheDependency dependency, out DateTime absoluteExpiration, out TimeSpan slidingExpiration)
    {
    int CacheOutTime = ConfigHelperBLL.CacheOutTime;
    expensiveObject = GetProclamationList_ForCache(0, 30);
    dependency = null;
    absoluteExpiration = DateTime.Now.AddSeconds(CacheOutTime);
    slidingExpiration = Cache.NoSlidingExpiration;
    }

    //实现调用方法

    public static int CacheOutTime
    {
    get
    {
    int time = 0;
    if(!int.TryParse(System.Configuration.ConfigurationManager.AppSettings["CacheOutTime"],out time))
    {
    time = 3;
    }
    return time;
    }
    }

  • 相关阅读:
    hdu 1392 fzu 1333 Surround the Trees 简单凸包
    STL的应用 multiset bitset next_permutation
    hdu 3711 Binary Number 位运算(^ 与&)的应用
    鸽舍原理
    hdu 4002 Find the maximum 2011 大连网络赛 1002 Find the maximum
    组合数学
    Delphi程序破解技术概要
    NET的URL怎么静态化?
    David I谈Delphi的现状及未来发展方向
    使用Dede破解Delphi软件实战
  • 原文地址:https://www.cnblogs.com/dandanwozhishidan/p/5238774.html
Copyright © 2011-2022 走看看