/// <summary>
        /// 初始化一个<see cref="DefaultRedisCacheProvider"/>类型的实例
        /// </summary>
        /// <param name="dbProvider">Redis数据库提供程序</param>
        /// <param name="serializer">缓存序列化器</param>
        /// <param name="options">Redis选项</param>
        /// <param name="log">日志</param>
        public DefaultRedisCacheProvider(IRedisDatabaseProvider dbProvider, ICacheSerializer serializer,
                                         IOptionsMonitor <RedisOptions> options, ILog log = null)
        {
            Check.NotNull(dbProvider, nameof(dbProvider));
            Check.NotNull(serializer, nameof(serializer));

            this._dbProvider    = dbProvider;
            this._serializer    = serializer;
            this._options       = options.CurrentValue;
            this._log           = log ?? NullLog.Instance;
            this._cache         = _dbProvider.GetDatabase();
            this._servers       = _dbProvider.GetServerList();
            this.CacheStatsInfo = new CacheStatsInfo();
        }
        /// <summary>
        /// 初始化一个<see cref="DefaultRedisCacheProvider"/>类型的实例
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="dbProviders">Redis数据库提供程序列表</param>
        /// <param name="serializer">缓存序列化器</param>
        /// <param name="options">Redis选项</param>
        /// <param name="log">日志</param>
        public DefaultRedisCacheProvider(string name, IEnumerable <IRedisDatabaseProvider> dbProviders, ICacheSerializer serializer,
                                         IOptionsMonitor <RedisOptions> options, ILog log = null)
        {
            Check.NotNullOrEmpty(dbProviders, nameof(dbProviders));
            Check.NotNull(serializer, nameof(serializer));

            this._dbProvider    = dbProviders.FirstOrDefault(x => x.DbProviderName.Equals(name));
            this._serializer    = serializer;
            this._options       = options.CurrentValue;
            this._log           = log ?? NullLog.Instance;
            this._cache         = _dbProvider.GetDatabase();
            this._servers       = _dbProvider.GetServerList();
            this.CacheStatsInfo = new CacheStatsInfo();

            this.Name = name;
        }
Пример #3
0
 /// <summary>
 /// 初始化一个<see cref="RedisDatabaseProvider"/>类型的实例
 /// </summary>
 /// <param name="name">名称</param>
 /// <param name="options">Redis选项</param>
 public RedisDatabaseProvider(string name, RedisOptions options)
 {
     _options = options.DbConfig;
     _connectionMultiplexer = new Lazy <ConnectionMultiplexer>(CreateConnectionMultiplexer);
     DbProviderName         = name;
 }