Exemple #1
0
        public CrawlerAddressRegistrationService(
            ILogger <CrawlerAddressRegistrationService> logger,
            IRedisConnectionWrapper redisConnectionWrapper,
            IOptions <CrawlerAddressRegistrationOptions> options)
        {
            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (redisConnectionWrapper is null)
            {
                throw new ArgumentNullException(nameof(redisConnectionWrapper));
            }

            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.Value is null)
            {
                throw new ArgumentException(
                          "The provided configuration object does not contain valid settings for crawler address registration.",
                          nameof(options));
            }

            EnableRecordingIgnoredLinks = options.Value.EnableRecordingIgnoredLinks;
            redisDatabase = redisConnectionWrapper.ConnectionMultiplexer.GetDatabase();

            logger.LogInformation("Recording ignored links is {@EnableRecordingIgnoredLinksInfoText}.", EnableRecordingIgnoredLinks ? "enabled" : "disabled");
        }
Exemple #2
0
 public RedisCacheManager(IRedisConnectionWrapper redisConnectionWrapper,
                          IMemoryCacheManager memoryCacheManager)
 {
     _redisConnectionWrapper = redisConnectionWrapper;
     _memoryCacheManager     = memoryCacheManager;
     this._db = _redisConnectionWrapper.Database();
 }
        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);
 }
 public RedisPipelineContext(IRedisConnectionWrapper redisManager, RedisPipelineConfig config, Action <string> logAction = null)
 {
     _redisManager = redisManager;
     _config       = config;
     _db           = _redisManager.GetDatabase(_config.DBSpace);
     _logAction    = logAction;
 }
Exemple #6
0
 public DistributeCacheManager(IDistributedCache distributedCache,
                               PerRequestCacheManager perRequestCacheManager,
                               IRedisConnectionWrapper redisConnectionWrapper)
 {
     _distributedCache       = distributedCache;
     _perRequestCacheManager = perRequestCacheManager;
     _redisConnectionWrapper = redisConnectionWrapper;
 }
Exemple #7
0
        public SubscriptionProcessor(IServiceUpdateWatchdog serviceUpdateWatchdog, IRedisConnectionWrapper redisWrapper, ILoggerFactory loggerFactory)
        {
            _serviceUpdateWatchdog  = serviceUpdateWatchdog;
            _redisConnectionWrapper = redisWrapper;
            _logger = loggerFactory.CreateLogger <SubscriptionProcessor>();

            StatusStorage = new ConcurrentDictionary <string, UpdatingService>();
        }
Exemple #8
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();
 }
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
        {
            // ConnectionMultiplexer.Connect只应调用一次并在调用者之间共享
            this._connectionWrapper = connectionWrapper;

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

            this._memoryCacheManager = new MemoryCacheManager();   //暂时这样
        }
Exemple #10
0
        public RedisCacheManager(IRedisConnectionWrapper connectionWrapper)
        {
            //    if (String.IsNullOrEmpty(redisConnString))
            //        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.Database();
        }
Exemple #11
0
        /// <summary>
        /// static Ctor
        /// </summary>
        static RedisCacheManagerTests()
        {
            var config = new WebConfig
            {
                RedisCachingEnable = true,
                RedisCachingConfig = "127.0.0.1:6379,allowAdmin=true"
            };

            _redisConnectionWrapper = new RedisConnectionWrapper(config);
            _redisCacheManager      = new RedisCacheManager(_redisConnectionWrapper);
        }
Exemple #12
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(/*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();
        }
Exemple #14
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>();
 }
 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();
 }
        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();
        }
Exemple #17
0
        public BundleScanningService(IRedisConnectionWrapper redisConnectionWrapper, IDateTimeProvider dateTimeProvider, IBundleQueryRepository bundleQueryRepository)
        {
            if (redisConnectionWrapper is null)
            {
                throw new ArgumentNullException(nameof(redisConnectionWrapper));
            }

            redisDatabase = redisConnectionWrapper.ConnectionMultiplexer.GetDatabase();

            this.bundleQueryRepository = bundleQueryRepository ?? throw new ArgumentNullException(nameof(bundleQueryRepository));
            this.dateTimeProvider      = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));
        }
        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);
        }
        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();
        }
Exemple #21
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
        }
Exemple #22
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>();
        }
Exemple #23
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>();
        }
Exemple #24
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();
        }
        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);
        }
Exemple #26
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();
        }
Exemple #27
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()));
        }
Exemple #28
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);
        }
Exemple #29
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);
        }
Exemple #30
0
        public SubAggregationService(
            IDateTimeProvider dateTimeProvider,
            IRedisConnectionWrapper redisConnectionWrapper,
            ISubQueryRepository subQueryRepository,
            ISubWriteRepository subWriteRepository)
        {
            if (redisConnectionWrapper is null)
            {
                throw new ArgumentNullException(nameof(redisConnectionWrapper));
            }

            redisDatabase = redisConnectionWrapper.ConnectionMultiplexer.GetDatabase();

            this.subQueryRepository = subQueryRepository ?? throw new ArgumentNullException(nameof(subQueryRepository));
            this.dateTimeProvider   = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));
            this.subWriteRepository = subWriteRepository ?? throw new ArgumentNullException(nameof(subWriteRepository));
        }