• 网页 缓存


    掉用缓存方法:

     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;
    }
    }

  • 相关阅读:
    进程间通信之数据共享--共享内存
    进程间通信之分工协作-信号灯
    进程间通信之分工协作--锁
    进程间通信之事件通知--信号
    进程间通信之数据传输--Socket
    c++模板特化
    DAG模型:嵌套矩形
    数字三角形
    c柔性数组结构成员
    模板
  • 原文地址:https://www.cnblogs.com/dandanwozhishidan/p/5238774.html
Copyright © 2020-2023  润新知