温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:NBear+NBear开发BBS系统源码
当前文件:
NBBS/Factory/CacheAccess.cs,打开代码结构图
NBBS/Factory/CacheAccess.cs,打开代码结构图1using System; 2
using System.Web; 3
using System.Web.Caching; 4
5
namespace NBBS.Factory 6
{ 7
/// <summary> 8
/// 控制类,用于缓存操作 9
/// </summary> 10
public sealed class CacheAccess 11
{ 12
/// <summary> 13
/// 将对象加入到缓存中 14
/// </summary> 15
/// <param name="cacheKey">缓存键</param> 16
/// <param name="cacheObject">缓存对象</param> 17
/// <param name="dependency">缓存依赖项</param> 18
public static void SaveToCache(string cacheKey, object cacheObject,CacheDependency dependency) 19
{ 20
Cache cache = HttpRuntime.Cache; 21
cache.Insert(cacheKey, cacheObject, dependency); 22
} 23
24
/// <summary> 25
/// 从缓存中取得对象,不存在则返回null 26
/// </summary> 27
/// <param name="cacheKey">缓存键</param> 28
/// <returns>获取的缓存对象</returns> 29
public static object GetFromCache(string cacheKey) 30
{ 31
Cache cache = HttpRuntime.Cache; 32
33
return cache[cacheKey]; 34
} 35
} 36
} 37





}