Пример #1
0
        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);
        }
Пример #2
0
 public RedisClient(RedisOption option)
 {
     _option = option;
     _connectionMultiplexer = ConnectionMultiplexer.Connect(option.RedisConnectionString);
 }