| | | 1 | | using Intentum.Distributed.Locking; |
| | | 2 | | using Intentum.Distributed.RateLimiting; |
| | | 3 | | using Intentum.Distributed.Redis; |
| | | 4 | | using Microsoft.Extensions.DependencyInjection; |
| | | 5 | | using StackExchange.Redis; |
| | | 6 | | |
| | | 7 | | namespace Intentum.Distributed; |
| | | 8 | | |
| | | 9 | | public static class DistributedRedisExtensions |
| | | 10 | | { |
| | | 11 | | public static IServiceCollection AddIntentumDistributedRedis( |
| | | 12 | | this IServiceCollection services, |
| | | 13 | | string connectionString) |
| | 0 | 14 | | { |
| | 0 | 15 | | var multiplexer = ConnectionMultiplexer.Connect(connectionString); |
| | 0 | 16 | | services.AddSingleton<IConnectionMultiplexer>(multiplexer); |
| | 0 | 17 | | services.AddSingleton<IDistributedLock, RedisDistributedLock>(); |
| | 0 | 18 | | services.AddSingleton<IDistributedRateLimiter, RedisDistributedRateLimiter>(); |
| | 0 | 19 | | return services; |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | public static IServiceCollection AddIntentumDistributedRedis( |
| | | 23 | | this IServiceCollection services, |
| | | 24 | | IConnectionMultiplexer multiplexer) |
| | 0 | 25 | | { |
| | 0 | 26 | | services.AddSingleton(multiplexer); |
| | 0 | 27 | | services.AddSingleton<IDistributedLock, RedisDistributedLock>(); |
| | 0 | 28 | | services.AddSingleton<IDistributedRateLimiter, RedisDistributedRateLimiter>(); |
| | 0 | 29 | | return services; |
| | 0 | 30 | | } |
| | | 31 | | } |