Example #1
0
 public static IServiceCollection AddCache(this IServiceCollection services, IHostEnvironment environment, LevyTransferMatchingWeb config)
 {
     if (environment.IsDevelopment())
     {
         services.AddDistributedMemoryCache();
     }
     else
     {
         services.AddStackExchangeRedisCache(
             options => { options.Configuration = config.RedisConnectionString; });
     }
     return(services);
 }
        public static IServiceCollection AddDasDataProtection(this IServiceCollection services, LevyTransferMatchingWeb webConfiguration, IWebHostEnvironment environment)
        {
            if (!environment.IsDevelopment())
            {
                var redisConnectionString      = webConfiguration.RedisConnectionString;
                var dataProtectionKeysDatabase = webConfiguration.DataProtectionKeysDatabase;

                var redis = ConnectionMultiplexer.Connect($"{redisConnectionString},{dataProtectionKeysDatabase}");

                services.AddDataProtection()
                .SetApplicationName("das-levy-transfer-matching-web")
                .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
            }
            return(services);
        }