Cache在webform开发中经常用到,提高页面的浏览速度以及客户端利用率
using
System;
using System.Web;
using System.Web.Caching;
namespace Beasyer.Lib
... {
/**//// <summary>
/// 缓存相关的操作类
/// </summary>
public class DataCache
...{
/**//// <summary>
/// 获取当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <returns></returns>
public static object GetCache(string CacheKey)
...{
Cache objCache = HttpRuntime.Cache;
return objCache[CacheKey];
}
/**//// <summary>
/// 设置当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <param name="objObject"></param>
public static void SetCache(string CacheKey, object objObject)
...{
Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject);
}
}
}
using System.Web;
using System.Web.Caching;
namespace Beasyer.Lib
... {
/**//// <summary>
/// 缓存相关的操作类
/// </summary>
public class DataCache
...{
/**//// <summary>
/// 获取当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <returns></returns>
public static object GetCache(string CacheKey)
...{
Cache objCache = HttpRuntime.Cache;
return objCache[CacheKey];
}
/**//// <summary>
/// 设置当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <param name="objObject"></param>
public static void SetCache(string CacheKey, object objObject)
...{
Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject);
}
}
}