Skip to content
Redlock Redis-based distributed locks implementation in .Net
C#
Branch: master
Clone or download
Latest commit 8adaa9f Dec 1, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md

README.md

Redlock4Net

Redlock Redis-based distributed locks implementation in .Net See More:Distributed locks with Redis

Dependencies

StackExchange.Redis GitHub Nuget

Usage

ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("127.0.0.0:6379,allowAdmin=true");
var redLockFactory = new RedLockFactory(connection);
using (var redLock = redLockFactory.GetLock("lock", TimeSpan.FromMinutes(10), 2, TimeSpan.FromSeconds(2)))
{
    Console.WriteLine("[A] Try to get lock");
    if (redLock.IsAcquired)
    {
        Console.WriteLine("[A] Geted lock");
        Thread.Sleep(10000);
    }
    else
    {
        Console.WriteLine("[A] UnAcquired");
    }
}
You can’t perform that action at this time.