public static IServiceCollection AddRedisStorage(this IServiceCollection serviceCollection, RedisCacheOptions options, int port = 6379) { if (serviceCollection == null) { throw new ArgumentNullException(nameof(serviceCollection)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (!IsIpAddress(options.Configuration)) { IPHostEntry ip = Dns.GetHostEntryAsync(options.Configuration).Result; var ipAddress = string.Empty; foreach (var adr in ip.AddressList) { var strIp = adr.ToString(); if (IsIpAddress(strIp)) { ipAddress = strIp; break; } } options.Configuration = ipAddress; } var redisStorage = new RedisStorage(options, port); serviceCollection.AddSingleton <IAuthorizationCodeStore>(new RedisAuthorizationCodeStore(redisStorage)); serviceCollection.AddSingleton <ITokenStore>(new RedisTokenStore(redisStorage)); return(serviceCollection); }
public RedisTokenStore(RedisStorage storage) { _storage = storage; }
public RedisAuthorizationCodeStore(RedisStorage storage) { _storage = storage; }