public RedisLock( ICollection<ConnectionMultiplexer> redisCaches, string resource, TimeSpan expiryTime, TimeSpan? waitTime = null, TimeSpan? retryTime = null, Func<string, string> redisKeyFormatter = null, IRedLockLogger logger = null) { this.redisCaches = redisCaches; var formatter = redisKeyFormatter ?? DefaultRedisKeyFormatter; this.logger = logger ?? new NullLogger(); quorum = redisCaches.Count() / 2 + 1; quorumRetryCount = 3; quorumRetryDelayMs = 400; clockDriftFactor = 0.01; redisKey = formatter(resource); Resource = resource; LockId = Guid.NewGuid().ToString(); this.expiryTime = expiryTime; this.waitTime = waitTime; this.retryTime = retryTime; Start(); }
public RedisLockFactory(IEnumerable<EndPoint> redisEndPoints, IRedLockLogger logger) { redisCaches = CreateRedisCaches(redisEndPoints.ToArray()); this.logger = logger ?? new NullLogger(); }