手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net下Cache 缓存操作类代码
asp.net下Cache 缓存操作类代码
摘要:复制代码代码如下:usingSystem.Collections.Generic;usingSystem.Web;usingSystem;n...

复制代码 代码如下:

using System.Collections.Generic;

using System.Web;

using System;

namespace DataAccess

{

/// <summary>

/// 缓存控制类

/// </summary>

public class CacheControl

{

public static List<string> AllUseCacheKey = new List<string>();

/// <summary>

/// 添加缓存

/// </summary>

/// <param name="key"></param>

/// <param name="value"></param>

/// <param name="absoluteExpiration"></param>

public static void AddCache(string key, object value, DateTime absoluteExpiration)

{

if (!AllUseCacheKey.Contains(key))

{

AllUseCacheKey.Add(key);

}

HttpContext.Current.Cache.Add(key, value, null, absoluteExpiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);

}

/// <summary>

/// 移除缓存

/// </summary>

/// <param name="key"></param>

public static void RemoveCache(string key)

{

if (AllUseCacheKey.Contains(key))

{

AllUseCacheKey.Remove(key);

}

HttpContext.Current.Cache.Remove(key);

}

/// <summary>

/// 清空使用的缓存

/// </summary>

public static void ClearCache()

{

foreach (string value in AllUseCacheKey)

{

HttpContext.Current.Cache.Remove(value);

}

AllUseCacheKey.Clear();

}

}

}

【asp.net下Cache 缓存操作类代码】相关文章:

asp.net(c#)下Jmai去说明 使用与下载

Asp.net 无限级分类实例代码

asp.net中WebResponse 跨域访问实例代码

asp.net Repeater中使用if的代码

asp.net下OnClientClick的妙用!

asp.net中Repeater控件用法笔记

asp.net下Response.ContentType类型汇总

Asp.net(C#)实现验证码功能代码

asp.net下 jquery jason 高效传输数据

asp.net下PageMethods使用技巧

精品推荐
分类导航