Esempio n. 1
0
        public RedisLockService Initialize(
            RedisOptions redisOptions,
            string keyPrefix      = "default",
            TimeSpan?timeOut      = null,
            TimeSpan?holdDuration = null
            )
        {
            _redisOptions = redisOptions;
            _keyPrefix    = keyPrefix;

            Ensure.NotNull(_redisOptions, "redisOptions");
            Ensure.NotNull(_redisOptions.ConnectionString, "redisOptions.ConnectionString");
            Ensure.Positive(_redisOptions.DatabaseId, "redisOptions.DatabaseId");
            Ensure.NotNull(_keyPrefix, "keyPrefix");

            if (timeOut.HasValue)
            {
                _timeOutTimeSpan = timeOut.Value;
            }

            if (holdDuration.HasValue)
            {
                _holdDurationTimeSpan = holdDuration.Value;
            }

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);

            _redisProvider = new RedisProvider(_redisOptions);

            _redisDatabase = _redisProvider.GetDatabase();

            return(this);
        }
Esempio n. 2
0
        public RedLockQueueService Initialize(
            RedisOptions redisOptions,
            string keyPrefix  = "enode",
            TimeSpan?timeout  = null,
            TimeSpan?expiries = null
            )
        {
            _redisOptions = redisOptions;
            _keyPrefix    = keyPrefix;

            Ensure.NotNull(_redisOptions, "redisOptions");
            Ensure.NotNull(_redisOptions.ConnectionString, "redisOptions.ConnectionString");
            Ensure.Positive(_redisOptions.DatabaseId, "redisOptions.DatabaseId");
            Ensure.NotNull(_keyPrefix, "keyPrefix");

            if (timeout.HasValue)
            {
                _timeout = timeout.Value;
            }

            if (expiries.HasValue)
            {
                _expiries = expiries.Value;
            }

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);

            _redisProvider = new RedisProvider(_redisOptions);

            _redisDatabase = _redisProvider.GetDatabase();

            return(this);
        }