Ejemplo n.º 1
0
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
        {
            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase();
        }
 public RedisCacheManager(IHttpContextAccessor httpContextAccessor, IRedisConnectionWrapper connectionWrapper, MotelConfig config)
 {
     _perRequestCache   = new PerRequestCache(httpContextAccessor);
     _connectionWrapper = connectionWrapper;
     _config            = config;
     _db = connectionWrapper.GetDatabase(config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Cache);
 }
Ejemplo n.º 3
0
 public RedisPipelineContext(IRedisConnectionWrapper redisManager, RedisPipelineConfig config, Action <string> logAction = null)
 {
     _redisManager = redisManager;
     _config       = config;
     _db           = _redisManager.GetDatabase(_config.DBSpace);
     _logAction    = logAction;
 }
Ejemplo n.º 4
0
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
        {
            // ConnectionMultiplexer.Connect只应调用一次并在调用者之间共享
            this._connectionWrapper = connectionWrapper;

            //默认就使用Redis 16个中的第一个数据库吧
            this._db = _connectionWrapper.GetDatabase();

            this._memoryCacheManager = new MemoryCacheManager();   //暂时这样
        }
Ejemplo n.º 5
0
 public RedisCacheManage(IRedisCache redisCache, IRedisConnectionWrapper redisConnectionWrapper, OarmsConfig config)
 {
     if (string.IsNullOrEmpty(config.RedisCachingConnectionString))
     {
         throw new Exception("Redis连接字符串不能为空!");
     }
     this._perRequestCacheManager = redisCache;
     this._connectionWrapper      = redisConnectionWrapper;
     this._db = _connectionWrapper.GetDatabase();
 }
Ejemplo n.º 6
0
 public RedisCacheManager(ICacheManager perRequestCacheManager, IRedisConnectionWrapper connectionWrapper, ISettings settings)
 {
     if (string.IsNullOrEmpty(settings.Cachings.RedisConnectionString))
     {
         throw new Exception("Redis connection string is empty");
     }
     this._settings = settings;
     this._perRequestCacheManager = perRequestCacheManager;
     this._connectionWrapper      = connectionWrapper;
     this._db = connectionWrapper.GetDatabase();
 }
Ejemplo n.º 7
0
 public RedisCacheManager(DbgoConfig config, IRedisConnectionWrapper connectionWrapper)
 {
     if (String.IsNullOrEmpty(config.RedisCachingConnectionString))
     {
         throw new Exception("Redis connection string is empty");
     }
     // ConnectionMultiplexer.Connect should only be called once and shared between callers
     this._connectionWrapper = connectionWrapper;
     this._db = _connectionWrapper.GetDatabase();
     //this._perRequestCacheManager = EngineContext.Current.Resolve<ICacheManager>();
 }
Ejemplo n.º 8
0
        public RedisCacheManager(/*ICacheManager perRequestCacheManager,*/
            IRedisConnectionWrapper connectionWrapper,
            GrandConfig config)
        {
            if (string.IsNullOrEmpty(config.RedisCachingConnectionString))
                throw new Exception("Redis connection string is empty");

            this._connectionWrapper = connectionWrapper;
            
            this._db = _connectionWrapper.GetDatabase();
        }
Ejemplo n.º 9
0
        public RedisCacheManager(IAppConfiguration config, IStaticCacheManager perRequestCacheManager,
                                 IRedisConnectionWrapper connectionWrapper)
        {
            _config = config;
            _perRequestCacheManager = perRequestCacheManager;

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _database = _connectionWrapper.GetDatabase(_config.CacheDatabaseIndex);
        }
        public RedisCacheManager(DapperRepositoryConfig config, IRedisConnectionWrapper connectionWrapper)
        {
            if (String.IsNullOrEmpty(config.RedisCachingConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase();
        }
Ejemplo n.º 11
0
        public RedisCacheManager(
            IRedisConnectionWrapper connectionWrapper, string strConn)
        {
            if (string.IsNullOrEmpty(strConn))
            {
                throw new Exception("Redis connection string is empty");
            }
            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            this._connectionWrapper = connectionWrapper;

            this._db = _connectionWrapper.GetDatabase();
        }
Ejemplo n.º 12
0
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper,
                                 ApplicationSettings config)
        {
            if (string.IsNullOrEmpty(config.Cache.GetConnectionString()))
            {
                throw new Exception("Redis connection string is empty");
            }

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;
            _db = _connectionWrapper.GetDatabase(config.Cache.Database ?? (int)RedisDatabaseNumber.Cache);
        }
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper, RedisSettings config)
        {
            _config = config;
            if (string.IsNullOrEmpty(_config.RedisConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase(_config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Cache);
        }
Ejemplo n.º 14
0
        public RedisCacheManager(NopConfig config, IRedisConnectionWrapper connectionWrapper)
        {
            if (String.IsNullOrEmpty(config.RedisCachingConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            // ConnectionMultiplexer.Connect 只应调用一次并在调用方之间共享
            this._connectionWrapper = connectionWrapper;

            this._db = _connectionWrapper.GetDatabase();
            this._perRequestCacheManager = EngineContext.Current.Resolve <ICacheManager>();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 自定义键前缀 - 构造函数
        /// </summary>
        /// <param name="connectionWrapper">redis连接池</param>
        /// <param name="keyPrefix">键 前缀</param>
        /// <param name="expiry">失效时间</param>
        public RedisClient(IRedisConnectionWrapper connectionWrapper, string keyPrefix, TimeSpan expiry)
        {
            if (string.IsNullOrWhiteSpace(keyPrefix) || !Regex.IsMatch(@"^[a-zA-Z]\w+$", keyPrefix))
            {
                throw new Exception(@"redis键前缀正确格式必须符合:^[a-zA-Z]\w+$");
            }

            ConnectionWrapper = connectionWrapper;
            Db            = ConnectionWrapper.GetDatabase();
            KeyPrefix     = keyPrefix;
            Expiration    = expiry;
            RealKeySuffix = "d.r.s"; //data.real.suffix
        }
Ejemplo n.º 16
0
        public RedisCacheManager(string connnectionString = "127.0.0.1")
        {
            if (String.IsNullOrEmpty(connnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            this._connectionWrapper = new RedisConnectionWrapper(connnectionString);

            this._db = _connectionWrapper.GetDatabase();
            this._perRequestCacheManager = new MemoryCacheManager();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="connectionWrapper">已初始化的redis连接管理器</param>
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
        {
            if (connectionWrapper == null)
            {
                throw new ArgumentNullException("connectionWrapper");
            }

            this._connectionWrapper = connectionWrapper;
            this._db = _connectionWrapper.GetDatabase();

            //Unit tests need to annot the following code
            this._perRequestCacheManager = EngineContext.Current.Resolve <ICacheManager>();
        }
Ejemplo n.º 18
0
        public void RemoveByPattern(string pattern)
        {
            var _db = _redisConnectionWrapper.GetDatabase();

            foreach (var ep in _redisConnectionWrapper.GetEndPoints())
            {
                var server = _redisConnectionWrapper.GetServer(ep);
                var keys   = server.Keys(database: _db.Database, pattern: "*" + pattern + "*");
                foreach (var key in keys)
                {
                    Remove(key);
                }
            }
        }
Ejemplo n.º 19
0
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper,
                                 SmiConfig config)
        {
            if (string.IsNullOrEmpty(config.RedisConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase(config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Cache);

            _memoryCacheManager = new MemoryCacheManager(new MemoryCache(new MemoryCacheOptions()));
        }
Ejemplo n.º 20
0
        public RedisCacheManager(ICacheManager perRequestCacheManager,
                                 IRedisConnectionWrapper connectionWrapper)
        {
            if (string.IsNullOrEmpty(AppSettings.Caching.RedisConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            this._perRequestCacheManager = perRequestCacheManager;

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            this._connectionWrapper = connectionWrapper;

            this._db = _connectionWrapper.GetDatabase();
        }
Ejemplo n.º 21
0
        public RedisCacheManager(ICacheManager perRequestCacheManager,
                                 IRedisConnectionWrapper connectionWrapper,
                                 AppConfig config)
        {
            if (string.IsNullOrEmpty(config.RedisConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            _perRequestCacheManager = perRequestCacheManager;

            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase(config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Cache);
        }
Ejemplo n.º 22
0
        public RedisCacheManager(ICacheManager perRequestCacheManager,
                                 IRedisConnectionWrapper connectionWrapper,
                                 AnyConfig config)
        {
            if (string.IsNullOrEmpty(config.RedisConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            _perRequestCacheManager = perRequestCacheManager;

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase(config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Cache);
        }
Ejemplo n.º 23
0
        public RedisCacheManager(IHttpContextAccessor httpContextAccessor,
                                 IRedisConnectionWrapper connectionWrapper,
                                 NopConfig config) : base(config)
        {
            if (string.IsNullOrEmpty(config.RedisConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase(config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Cache);

            _perRequestCache = new PerRequestCache(httpContextAccessor);
        }
Ejemplo n.º 24
0
        public RedisCacheManager(IHttpContextAccessor httpContextAccessor,
                                 IRedisConnectionWrapper connectionWrapper)
        {
            _config = Singleton <AppSettings> .Instance[nameof(CacheConfig)];

            if (string.IsNullOrEmpty(_config.RedisCacheConfig.ConnectionString))
            {
                throw new Exception("Redis connection string is empty");
            }
            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db = _connectionWrapper.GetDatabase(_config?.RedisCacheConfig.RedisDatabaseId ??
                                                 (int)RedisDatabaseNumber.Cache);

            _perRequestCache = new PerRequestCache(httpContextAccessor);
        }
Ejemplo n.º 25
0
        public RedisCacheManager(
            ICacheManager perRequestCacheManager,
            IRedisConnectionWrapper connectionWrapper,
            CacheOptions config)
        {
            if (string.IsNullOrEmpty(config.RedisCachingConnection))
            {
                throw new Exception("Redis connection string is empty");
            }

            _perRequestCacheManager = perRequestCacheManager;

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db     = _connectionWrapper.GetDatabase();
            _config = config;
        }
Ejemplo n.º 26
0
        public RedisCacheManager(
            ICacheManager perRequestCacheManager,
            IRedisConnectionWrapper connectionWrapper,
            IOptionsMonitor <ShopConfig> config)
        {
            if (string.IsNullOrWhiteSpace(config?.CurrentValue?.RedisCachingConnection))
            {
                throw new Exception("Redis connection string is empty");
            }

            _perRequestCacheManager = perRequestCacheManager;

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db     = _connectionWrapper.GetDatabase();
            _config = config.CurrentValue;
        }
Ejemplo n.º 27
0
 public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
 {
     ConnectionWrapper = connectionWrapper;
     Db = ConnectionWrapper.GetDatabase();
 }
Ejemplo n.º 28
0
 public RedisCacheManager(IRedisConnectionWrapper connection)
 {
     _connection   = connection;
     _database     = _connection.GetDatabase();
     _instanceName = connection.GetInstanceName();
 }
 public RedisPluginsInfo(INopFileProvider fileProvider, IRedisConnectionWrapper connectionWrapper, NopConfig config)
     : base(fileProvider)
 {
     _db = connectionWrapper.GetDatabase(config.RedisDatabaseId ?? (int)RedisDatabaseNumber.Plugin);
 }
Ejemplo n.º 30
0
 public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
 {
     this._connectionWrapper = connectionWrapper;
     this._db = _connectionWrapper.GetDatabase();
 }