/// <summary> /// Inicializa Los Managers de las policies definidas en archivo de configuración /// </summary> private static void Initialize() { _instances = new Dictionary <string, ICacheManager>(); //Inicializo la configuración de políticas CacheConfigurationManager.Initialize(); //Agrego cada política de cache a la lista de políticas foreach (CachePolicyConfiguration cachePolicyConf in CacheConfigurationManager.GetPolicyConfigurationList()) { switch (cachePolicyConf.CacheType) { case CacheType.LocalCache: _instances.Add(cachePolicyConf.Name, new LocalCacheManager(cachePolicyConf)); break; case CacheType.NoCache: _instances.Add(cachePolicyConf.Name, new NoCacheManager()); break; default: throw new CacheException(string.Format( Messages.InvalidCacheType, cachePolicyConf.CacheType.ToString())); } } }
/// <summary> /// Obtiene el manejador de cache según configuración /// </summary> /// <returns>Manejador de cache configurado</returns> public static ICacheManager GetCache(string policyName) { ICacheManager cacheManager = null; CachePolicyConfiguration policyConf = CacheConfigurationManager.GetPolicyConfiguration(policyName); if (Cache.Instances.TryGetValue(policyConf.Name, out cacheManager) == false) { throw new CacheException(Messages.InexistentPolicyName, new ArgumentNullException()); } return(cacheManager); }