webcache.cs
来自「1、用SQL查询器打开install目录下的dooogo.sql运行之后创建数据」· CS 代码 · 共 52 行
CS
52 行
using System;
using System.Web;
using System.Web.Caching;
namespace Club.Framework.Util
{
/// <summary>
/// Allows caching in application in applications hosted inside and out of IIS
/// </summary>
public class WebCache
{
private WebCache(){}
public static Cache Cache(HttpContext context)
{
return GetCache(context);
}
public static Cache Cache()
{
return Cache(HttpContext.Current);
}
public static void AssemblyCacheDependency(string cacheKey, object obj)
{
AssemblyCacheDependency(cacheKey,obj,HttpContext.Current);
}
public static void AssemblyCacheDependency(string cacheKey, object obj, HttpContext context)
{
if(cacheKey != null && obj != null)
{
CacheDependency cacheDependency = new CacheDependency(obj.GetType().Assembly.Location);
WebCache.Cache().Insert(cacheKey,obj,cacheDependency);
}
}
private static Cache GetCache(HttpContext context)
{
if(context != null)
{
return context.Cache;
}
else
{
return HttpRuntime.Cache;
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?