⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webcache.cs

📁 1、用SQL查询器打开install目录下的dooogo.sql运行之后创建数据库dooogo。 2、然后打开web.config修改 <DbProvider type="Club.Fram
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -