Open-source Lightweight Distributed Lock Library (Based on Redis)
nuget | stats |
---|---|
services.AddDistributedLock4Redis(configure =>
{
configure.KeyPrefix = "MyStack";
configure.ConnectionString = "127.0.0.1:6379,password=123456";
});
// Acquire Lock
using (var handle = await distributedLock.TryAcquireAsync("Foo"))
{
if (handle != null)
{
// Write your logical code
}
}
MIT