• .net Cache的用法


     HttpContext.Current.Cache 使用方法

    .net Cache 怎么使用

       /// <summary>
            /// 简单创建/修改Cache,前提是这个值是字符串形式的
            /// </summary>
            /// <param name="strCacheName">Cache名称</param>
            /// <param name="strValue">Cache值</param>
            /// <param name="iExpires"></param>
            /// <param name="inType">1为 在iExpires分过期 绝对时间 ,2为在iExpires之后如果没有人访问 则移除</param>
            public static void Insert(string strCacheName, object strValue, int iExpires, int inType)
            {
                //缓存依赖项
                CacheDependency mydepen = new CacheDependency(HttpContext.Current.Server.MapPath("~") + @"//cache.xml");
                if (inType == 1)
                {
                    DateTime absoluteExpiration = DateTime.Now.AddMinutes(iExpires);
                    HttpContext.Current.Cache.Insert(strCacheName, strValue, mydepen, absoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                }
                else if (inType == 2)
                {
                    TimeSpan slidingExpiration = TimeSpan.FromMinutes(iExpires);
                    HttpContext.Current.Cache.Insert(strCacheName, strValue, mydepen, System.Web.Caching.Cache.NoAbsoluteExpiration, slidingExpiration, CacheItemPriority.Normal, null);

                }
            }

  • 相关阅读:
    #include<unistd.h>存在linux中,含有系统服务的函数
    Value Categories
    Main function
    Phases of translation
    Memory model
    Unqualified name lookup
    Qualified name lookup
    Name lookup
    Definitions
    Object lifetime
  • 原文地址:https://www.cnblogs.com/sxmny/p/3145907.html
Copyright © 2020-2023  润新知