public static IServiceCollection AddRedisHelper(this IServiceCollection services, Action <RedisOption> options) { if (options == null) { throw new ArgumentNullException("options cannot be null"); } var redisOption = new RedisOption(); options(redisOption); services.AddSingleton(redisOption); services.AddSingleton(typeof(RedisClient)); return(services); }
public RedisClient(RedisOption option) { _option = option; _connectionMultiplexer = ConnectionMultiplexer.Connect(option.RedisConnectionString); }