public LocalCacheService(IConnectionMultiplexer connectionMultiplexer, IEntityCache <TEntity> entityCache, ILogger logger, IEntityCacheOptions redisConfiguration) : base(redisConfiguration) { _entityCache = entityCache; _logger = logger; _redisConfiguration = redisConfiguration; // Configure redis things ConnectionMultiplexer = connectionMultiplexer; Db = connectionMultiplexer.GetDatabase(); SubscribtionChannel = new RedisChannel($"__keyspace@0__:{KeyPrefix}:*", RedisChannel.PatternMode.Pattern); }
protected CacheServiceBase(IEntityCacheOptions redisConfiguration) { // Set naming var componentPrefix = typeof(TEntity).Assembly.GetName().Name.ToLowerInvariant().Replace('.', ':'); var cachePrefix = string.IsNullOrEmpty(redisConfiguration.CacheKeyPrefix) ? componentPrefix : redisConfiguration.CacheKeyPrefix + ":" + componentPrefix; EntityName = typeof(TEntity).Name; KeyPrefix = $"{cachePrefix}:Entity:{EntityName}"; TrackingSetKey = $"{cachePrefix}:Tracker:{EntityName}"; }
public CentralizedCacheService(IConnectionMultiplexer connectionMultiplexer, IEntityCacheOptions redisConfiguration, ILogger logger) : base(redisConfiguration) { _db = connectionMultiplexer.GetDatabase(); _logger = logger; }
private static void RegisterEntityCacheConfiguration(this ContainerBuilder containerBuilder, IEntityCacheOptions entityCacheOptions) { containerBuilder.Register <ILogger>((c, p) => { return(new LoggerConfiguration().CreateLogger()); }).SingleInstance(); containerBuilder.RegisterInstance(entityCacheOptions).AsImplementedInterfaces().SingleInstance(); containerBuilder.Register(c => { var redisOptions = new ConfigurationOptions { AllowAdmin = true, Ssl = false, AbortOnConnectFail = entityCacheOptions.AbortOnConnectFail }; foreach (var endpoint in entityCacheOptions.Endpoints) { redisOptions.EndPoints.Add(endpoint); } var multiplexer = ConnectionMultiplexer.Connect(redisOptions); multiplexer.PreserveAsyncOrder = entityCacheOptions.PreserveAsyncOrder; return(multiplexer); }).As <IConnectionMultiplexer>().SingleInstance(); }
public static void RegisterEntityCacheDataProvider(this ContainerBuilder containerBuilder, IEntityCacheOptions entityCacheOptions) { containerBuilder.RegisterGeneric(typeof(CentralizedCacheService <>)).As(typeof(ICentralizedCacheService <>)).SingleInstance(); containerBuilder.RegisterEntityCacheConfiguration(entityCacheOptions); }
public static void RegisterEntityCacheDataConsumer(this ContainerBuilder containerBuilder, IEntityCacheOptions entityCacheOptions) { containerBuilder.RegisterGeneric(typeof(EntityCache <>)).As(typeof(IEntityCache <>)).SingleInstance(); containerBuilder.RegisterGeneric(typeof(LocalCacheService <>)).As(typeof(ILocalCacheService <>)).SingleInstance(); containerBuilder.RegisterEntityCacheConfiguration(entityCacheOptions); }