Ejemplo n.º 1
0
        internal RedisLock(SingleRedisDistributedLockOptions options, ILogger logger, IEnumerable <string> resources, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime, bool notUnlockWhenDispose, CancellationToken?cancellationToken)
        {
            Options              = options;
            _logger              = logger;
            ExpiryTime           = expiryTime;
            WaitTime             = waitTime;
            RetryTime            = retryTime;
            NotUnlockWhenDispose = notUnlockWhenDispose;
            CancellationToken    = cancellationToken;

            List <string> keyResources = new List <string>();

            foreach (string item in resources)
            {
                keyResources.Add(_prefix + Options.ApplicationName + item);
            }

            Resources = keyResources;

            List <string> resourceValues = new List <string>();

            for (int i = 0; i < Resources.Count(); ++i)
            {
                resourceValues.Add(SecurityUtil.CreateUniqueToken());
            }

            ResourceValues = resourceValues;
        }
Ejemplo n.º 2
0
        public SingleRedisDistributedLockManager(IOptions <SingleRedisDistributedLockOptions> options, ILogger <SingleRedisDistributedLockManager> logger)
        {
            _options = options.Value;
            _logger  = logger;

            InitLoadedLuas(_options.ConnectionSetting, _logger);

            _logger.LogInformation("SingleRedisDistributedLockManager初始化完成");
        }