public static IApiRateLimiterUserIdServiceRegistrationBackupProvider AddRedisCacheProvider(this IApiRateLimiterUserIdServiceRegistration servicef,
                                                                                                   Func <string> connectionString)
        {
            var    service = (ApiRateLimiterUserIdServiceRegistration)servicef;
            string redisConnectionString = connectionString();
            var    options = new RedisWithBackupStorageOptions
            {
                Prefix = service.Options.CachePrefix,
                RedisConnectionString = redisConnectionString
            };

            service.ServiceCollection.AddSingleton(options);
            service.ServiceCollection.AddSingleton <IAPIRateLimiterUserIdStorageProvider, RedisWithBackupStorage>();
            return(service);
        }
Esempio n. 2
0
 public RedisWithBackupStorage(RedisWithBackupStorageOptions options, IAPIRateLimiterUserIdBackupStorageProvider backupProvider = null)
 {
     _backupProvider   = backupProvider;
     _cachePrefix      = options.Prefix;
     _redisManagerPool = new RedisManagerPool(options.RedisConnectionString);
 }