Skip to content

Redlock Redis-based distributed locks implementation in .Net

License

Notifications You must be signed in to change notification settings

LiZhenNet/Redlock4Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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");
    }
}

About

Redlock Redis-based distributed locks implementation in .Net

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages