J'ai un système d'autorisation et de menustructure combiné sur notre backend. Pour des raisons de performances, la mise en cache EntLib est utilisée dans le client frontal (site Web MVC rel 1.0, IIS 5.1 local, serveur IIS 6.0, pas de cluster). Parfois, Cache.Contains retournera true, mais le contenu du cache est NULL. Je sais avec certitude que je l'ai rempli correctement, alors quel peut être le problème ici?Entlib Cache.Contains NULL problème
EDIT: lorsque je mets le cache à 1 minute et ajoute la clé cache 'A_Key', je verrai la clé revenir lors de l'inspection de CurrentCacheState. Lorsque je vois CurrentCacheState après 2 minutes, la clé est toujours là. Quand j'exécute 'contains', true est renvoyé. Quand j'exécute à nouveau 'contient', le cacheKey est parti! Problème de synchronisation?
Cordialement, Michel
Extrait:
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);
}
}
Et le 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)));
}
}