Ich habe ein kombiniertes Autorisierungs- und Menüstruktursystem auf unserem Backend. Aus Leistungsgründen wird das EntLib-Caching im Frontend-Client verwendet (MVC rel 1.0-Website, IIS 5.1 lokal, IIS 6.0-Server, kein Cluster).Entlib Cache.Contains NULL Problem
Manchmal gibt 'Cache.Contains' den Wert true zurück, aber der Inhalt des Cache ist NULL. Ich weiß mit Sicherheit, dass ich es richtig ausgefüllt habe. Was kann das Problem sein?
BEARBEITEN: wenn ich den Cache auf 1 Minute setze und den CacheKey 'A_Key' hinzufüge, sehe ich den Schlüssel, der zurückkommt, wenn ich den CurrentCacheState untersuche. Wenn ich CurrentCacheState nach 2 Minuten anzeigen, ist der Schlüssel immer noch vorhanden. Wenn ich 'contains' ausführe, wird true zurückgegeben. Wenn ich 'contains' erneut ausführe, ist der cacheKey weg! Synchronisationsproblem ??
Grüße, Michel
Auszug:
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);
}
}
Und der cachehelper:
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)));
}
}