zoukankan      html  css  js  c++  java
  • Code-Helper-Web:CacheHelper.cs

    ylbtech-Code-Helper-Web:CacheHelper.cs
    1.返回顶部
    1、
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Collections;
    
    namespace Core.WebHelper
    {
        /// <summary>
        /// 缓存辅助类
        /// </summary>
        public class CacheHelper
        {
            /// <summary>
            /// 获取数据缓存
            /// </summary>
            /// <param name="CacheKey"></param>
            public static object GetCache(string CacheKey)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                return objCache[CacheKey];
            }
    
            /// <summary>
            /// 设置数据缓存
            /// </summary>
            public static void SetCache(string CacheKey, object objObject)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                objCache.Insert(CacheKey, objObject);
            }
    
            /// <summary>
            /// 设置数据缓存
            /// </summary>
            public static void SetCache(string CacheKey, object objObject, TimeSpan Timeout)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                objCache.Insert(CacheKey, objObject, null, DateTime.MaxValue, Timeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);
            }
    
            /// <summary>
            /// 设置数据缓存
            /// </summary>
            public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                objCache.Insert(CacheKey, objObject, null, absoluteExpiration, slidingExpiration);
            }
    
            /// <summary>
            /// 移除指定数据缓存
            /// </summary>
            public static void RemoveAllCache(string CacheKey)
            {
                System.Web.Caching.Cache _cache = HttpRuntime.Cache;
                _cache.Remove(CacheKey);
            }
    
            /// <summary>
            /// 移除全部缓存
            /// </summary>
            public static void RemoveAllCache()
            {
                System.Web.Caching.Cache _cache = HttpRuntime.Cache;
                IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
                while (CacheEnum.MoveNext())
                {
                    _cache.Remove(CacheEnum.Key.ToString());
                }
            }
        }
    }
    2、
    2.返回顶部
     
    3.返回顶部
     
    4.返回顶部
     
    5.返回顶部
     
     
    6.返回顶部
     
    warn 作者:ylbtech
    出处:http://ylbtech.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    ASP.NET C# 邮件发送全解
    .NET应用框架架构设计实践 概述
    给大家推荐几个国外IT技术论坛
    IIS 内部运行机制
    大型网站后台架构的Web Server与缓存
    CMD 获得当前目录命令
    html之marquee详解
    sharepoint 富文本编辑器
    C# 将数据导出到Execl汇总(C/S和B/S)
    更改应用程序池的密码 (Windows SharePoint Services)
  • 原文地址:https://www.cnblogs.com/storebook/p/12676189.html
Copyright © 2011-2022 走看看