Exemplo n.º 1
0
 internal RedLockCSLock(RedLockCSLockFactory _this, RedlockCSharp.Redlock.Lock redLock, bool isAvailable)
 {
     this._this   = _this;
     _redLock     = redLock;
     Ttl          = (int)redLock.Ttl.TotalMilliseconds;
     _isAvailable = isAvailable;
     if (_isAvailable)
     {
         LockAtTime = redLock.LockAt;
     }
 }
Exemplo n.º 2
0
    public async Task <ILock> LockAsync(string ck, int ttl = 5000, int retry = 2, int retryDelay = 1000)
    {
        var lck = await redlock.LockAsync(ck, TimeSpan.FromMilliseconds(ttl), retry, retryDelay).ConfigureAwait(false);

        var ok = lck != null;

        if (!ok)
        {
            lck = new RedlockCSharp.Redlock.Lock(ck, Guid.NewGuid().ToString());
        }
        return(new RedLockCSLock(this, lck.Value, ok));
    }