【发布时间】:2009-03-23 13:56:49
【问题描述】:
我在我们的后端有一个组合的授权和菜单结构系统。 出于性能原因,EntLib 缓存用于前端客户端(MVC rel 1.0 网站,IIS 5.1 本地,IIS 6.0 服务器,无集群)。
有时 'Cache.Contains' 会返回 true,但缓存的内容为 NULL。我确定我填写正确,所以这里有什么问题?
编辑:当我将缓存设置为 1 分钟并添加缓存键“A_Key”时,我会在检查 CurrentCacheState 时看到键返回。当我在 2 分钟后查看 CurrentCacheState 时,密钥仍然存在。当我执行“包含”时,返回 true。当我再次执行“包含”时,cacheKey 不见了! 同步问题??
问候, 米歇尔
摘录:
if (IntranetCaching.Cache.Contains(cacheKey))
{
menuItems = (List<BoMenuItem>)IntranetCaching.Cache[cacheKey];
}
else
{
using (AuthorizationServiceProxyHelper authorizationServiceProxyHelper = new AuthorizationServiceProxyHelper())
{
menuItems = authorizationServiceProxyHelper.Proxy.SelectMenuByUserAndApplication(APPNAME, userName, AuthorizationType.ENUM_LOGIN);
IntranetCaching.Add(cacheKey, menuItems);
}
}
还有缓存助手:
public static class IntranetCaching
{
public static ICacheManager Cache { get; private set; }
static IntranetCaching()
{
Cache = CacheFactory.GetCacheManager();
}
public static void Add(string key, object value)
{
Cache.Add(
key
, value
, CacheItemPriority.Normal
, null
, new Microsoft.Practices.EnterpriseLibrary.Caching.Expirations.AbsoluteTime(TimeSpan.FromMinutes(10)));
}
}
【问题讨论】:
标签: caching null enterprise contains