public RedisCacheNotifier(string cacheName, RedisCacheNotifierPolicy policy) { this.policy = policy; this.cacheName = cacheName; this.sender = Guid.NewGuid().ToString(); this.convert = RedisConverterFactory.CreateConverter(policy.Converter); this.client = new RedisClient(policy.ConnectionString, policy.ClusterType, policy.MonitorPort, policy.MonitorIntervalMilliseconds); }
public RedisCacheNotifier(string name, RedisCacheNotifierPolicy policy) { this.name = name; this.policy = policy; this.log = NLog.LogManager.GetLogger(typeof(RedisCacheNotifier).FullName); this.cacheSubClients = new ConcurrentDictionary <string, RedisClient>(StringComparer.InvariantCultureIgnoreCase); this.cacheCallbacks = new ConcurrentDictionary <string, Func <CacheItemNotification, bool> >(StringComparer.InvariantCultureIgnoreCase); if (policy == null) { log.Error("Invalid Policy for Cache {0}", this.name); throw new ArgumentNullException(nameof(policy)); } if (!string.IsNullOrEmpty(policy.ConnectionName)) { this.connectionString = CacheManager.GetConnectionString(policy.ConnectionName)?.ConnectionString; if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentException( $"{nameof(ICacheConnectionString.ConnectionString)} not found for {nameof(policy.ConnectionName)} {policy.ConnectionName}", $"{nameof(policy)}.{nameof(policy.ConnectionName)}"); } } else if (!string.IsNullOrEmpty(policy.ConnectionString)) { this.connectionString = policy.ConnectionString; } else { throw new ArgumentException( $"{nameof(policy.ConnectionString)} is undefined", $"{nameof(policy)}.{nameof(policy.ConnectionString)}"); } this.sender = Guid.NewGuid().ToString(); this.convert = RedisConverterFactory.CreateConverter(policy.Converter); SubscribeToGeneralInvalidationMessage(policy.GeneralInvalidationChannel); }