.NET 缓存设计的使用说明(3)

/// <summary>
        /// 按秒缓存对象 并建立依赖项
        /// </summary>
        /// <param></param>
        /// <param></param>
        /// <param></param>
        /// <param></param>
        public static void Insert(string key, object obj, CacheDependency dep, int seconds)
        {
            Insert(key, obj, dep, seconds, CacheItemPriority.Normal);
        }

/// <summary>
        /// 按秒缓存对象 并建立具有优先级的依赖项
        /// </summary>
        /// <param></param>
        /// <param></param>
        /// <param></param>
        /// <param></param>
        /// <param></param>
        public static void Insert(string key, object obj, CacheDependency dep, int seconds, CacheItemPriority priority)
        {
            if (obj != null)
            {
                _cache.Insert(key, obj, dep, DateTime.Now.AddSeconds(Factor * seconds), TimeSpan.Zero, priority, null);
            }

}


        public static void MicroInsert(string key, object obj, int secondFactor)
        {
            if (obj != null)
            {
                _cache.Insert(key, obj, null, DateTime.Now.AddSeconds(Factor * secondFactor), TimeSpan.Zero);
            }
        }

/// <summary>
        /// 最大时间缓存
        /// </summary>
        /// <param></param>
        /// <param></param>
        public static void Max(string key, object obj)
        {
            Max(key, obj, null);
        }

/// <summary>
        /// 具有依赖项的最大时间缓存
        /// </summary>
        /// <param></param>
        /// <param></param>
        /// <param></param>
        public static void Max(string key, object obj, CacheDependency dep)
        {
            if (obj != null)
            {
                _cache.Insert(key, obj, dep, DateTime.MaxValue, TimeSpan.Zero, CacheItemPriority.AboveNormal, null);
            }
        }

/// <summary>
        /// Insert an item into the cache for the Maximum allowed time
        /// </summary>
        /// <param></param>
        /// <param></param>
        public static void Permanent(string key, object obj)
        {
            Permanent(key, obj, null);
        }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjdysx.html