RM.Common/DotNetCode/CacheHelper.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using RM.Common.DotNetConfig;
using System;
using System.Collections;
using System.Web;
using System.Web.Caching;
namespace RM.Common.DotNetCode
{
public class CacheHelper
{
public static void InsertFile(string key, object obj, string fileName)
{
CacheDependency dep = new CacheDependency(fileName);
HttpContext.Current.Cache.Insert(key, obj, dep);
}
public static void Insert(string key, object obj)
{
if (obj != null)
{
int expires = CommonHelper.GetInt(ConfigHelper.GetAppSettings("TimeCache"));
HttpContext.Current.Cache.Insert(key, obj, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, expires, 0));
}
}
public static bool IsExist(string strKey)
{
return HttpContext.Current.Cache[strKey] != null;
}
public static object GetCache(string key)
{
object result;
if (string.IsNullOrEmpty(key))
{
result = null;
}
else
{
if (ConfigHelper.GetAppSettings("IsCache") == "false")
{
result = null;
}
else
{
result = HttpContext.Current.Cache.Get(key);
}
}
return result;
}
public static T Get<T>(string key)
{
object obj = CacheHelper.GetCache(key);
return (obj == null) ? default(T) : ((T)((object)obj));
}
public static void RemoveAllCache(string CacheKey)
{
Cache _cache = HttpRuntime.Cache;
后面还有 14 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
