public UtilityService( IRepository <Testimonial> testimonialRepository, IRepository <CustomDictionary> customDictionaryRepository, IRepository <StockNotification> stockNotificationRepository, IRepository <Product> productRepository, IRepository <ProductPrice> productPriceRepository, IIPToCountry ipToCountry, ILogBuilder logBuilder, ISettingService settings, IEmailManager emailManager, ICacheNotifier cacheNotifier, IEnumerable <Lazy <ICacheManager, ICacheManagerMetadata> > cacheManagers, ISitemapGenerator sitemapGenerator, ICurrencyService currencyService, IGenericAttributeService genericAttributeService, IProductBuilder productBuilder, CacheSettings cacheSettings) { _testimonialRepository = testimonialRepository; _customDictionaryRepository = customDictionaryRepository; _stockNotificationRepository = stockNotificationRepository; _productRepository = productRepository; _productPriceRepository = productPriceRepository; _ipToCountry = ipToCountry; _settings = settings; _emailManager = emailManager; _cacheNotifier = cacheNotifier; _cacheManagers = cacheManagers; _sitemapGenerator = sitemapGenerator; _currencyService = currencyService; _genericAttributeService = genericAttributeService; _productBuilder = productBuilder; _cacheSettings = cacheSettings; _logger = logBuilder.CreateLogger(GetType().FullName); }
public CacheSynchronizer(ICache cache, ICacheNotifier notifier) { this.cache = cache; this.notifier = notifier ?? throw new ArgumentNullException(nameof(notifier)); notifier.Subscribe(cache.Name, OnCacheUpdated, OnNotifierStateChanged); }
public CacheSynchronizer(ICache cache, ICacheNotifier notifier) { this.cache = cache; this.notifier = notifier; this.notifier.Subscribe(CacheUpdated); }
/// <summary> /// Adds or sets a notifier by name /// This method is to be used during application initialization, it does not delete or replace the notifier if already in use! /// </summary> /// <param name="name"></param> /// <param name="notifier"></param> public void SetNotifier(string name, ICacheNotifier notifier) { if (notifier == null) { notifiers.TryRemove(name, out var _); } else { notifiers.AddOrUpdate(name, notifier, (k, v) => notifier); } }
/// <summary> /// Adds or sets a notifier by name /// This method is to be used during application intialization, it does not delete or replace the notifier if already in use! /// </summary> /// <param name="name"></param> /// <param name="notifier"></param> public static void SetNotifier(string name, ICacheNotifier notifier) { void Action() { if (notifier == null) { // ReSharper disable once UnusedVariable notifiers.TryRemove(name, out var oldValue); } else { notifiers.AddOrUpdate(name, notifier, (k, v) => notifier); } } SyncSet(notifiersSync, Action); }
public LayeredScopedCache(String name, LayeredScopedCachePolicy policy) : this(name, policy?.Level1CacheName, policy?.Level2CacheName) { this.policy = policy ?? throw new ArgumentNullException(nameof(policy)); if (policy.InvalidateLevel1OnLevel2Upsert) { if (this.level1 is NoCache) { policy.InvalidateLevel1OnLevel2Upsert = false; } else { level1Notifier = CacheManager.GetAssociatedNotifier(this.level1); if (level1Notifier == null) { throw new ApplicationException( "InvalidateLevel1OnLevel2Upsert requires level1 cache to have SyncProvider defined in policy: level1CacheName=" + policy.Level1CacheName); } } } }
public CacheSynchronizer(ICache cache, ICacheNotifier notifier) : this(cache, notifier, invalidateOnStateChange : false) { }
/// <summary> /// Adds or sets a notifier by name /// This method is to be used during application initialization, it does not delete or replace the notifier if already in use! /// </summary> /// <param name="name"></param> /// <param name="notifier"></param> public static void SetNotifier(string name, ICacheNotifier notifier) { CacheManagerInternals.SetNotifier(name, notifier); }
/// <summary>Associates a cache with a notifier</summary> /// <param name="cache"></param> /// <param name="notifier"></param> public static void Associate(ICache cache, ICacheNotifier notifier) { CacheManagerInternals.Associate(cache, notifier); }
public CacheSynchronizer(ICache cache, ICacheNotifier notifier) { this.cache = cache; notifier.Subscribe(cache.Name, OnCacheUpdated); }
/// <summary>Associates a cache with a notifier</summary> /// <param name="cache"></param> /// <param name="notifier"></param> public void Associate(ICache cache, ICacheNotifier notifier) { cacheNotifierAssociations.AddOrUpdate( cache.Name, c => notifier.Name, (c, n) => notifier.Name); }