📄 datacache.cs
字号:
using System;
using System.Web;
using System.Reflection;
namespace DLOA.DALFactory
{
/// <summary>
/// 缓存相关的操作类
/// </summary>
public class DataCache
{
/// <summary>
/// 获取当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <returns></returns>
public static object GetCache(string CacheKey,Type type)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
object obj = objCache[CacheKey];
//如果缓存中不存在该对象则创建
if (obj == null)
{
obj = System.Activator.CreateInstance(type);
SetCache(CacheKey, obj);
}
return obj;
}
/// <summary>
/// 设置当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <param name="objObject"></param>
public static void SetCache(string CacheKey, object objObject)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -