DistributedLeaseManager
2.0.0
간단한 C#/. NET 분산 임대/잠금 관리자 (DLM) 구현.
https://github.com/fbeltrao/azftions-distributed-locking에서 영감을 얻었습니다
README 지침에 따라리스 스토리지 구현 중 하나를 설치하십시오.
컨트롤러/서비스 내부에서 IDistributedLeaseManager 를 주입하고 TryAcquireLease 메소드를 호출하십시오. 결과가 성공했는지 확인하십시오 - 그렇다면 작업을 진행할 수 있습니다. 그렇지 않으면 다른 사람이 임대를 인수했습니다.
await using var leaseResult = await leaseManager . TryAcquireLease ( resourceId , TimeSpan . FromSeconds ( 5 ) ) ;
if ( ! leaseResult . IsSuccessful )
{
// Someone else has required the lease for the resource.
// You may want to either retry the acqusition or abort the operation.
}
else
{
// You are the lease owner now and can safely process the resource.
// The lease will be released either when the leaseResult gets disposed
// or when the lease expires (in the example above, in 5 seconds)
} 저자가 제공 한 것과 다른 임대 스토리지를 사용하려면 DistributedLeaseManager.Core 라이브러리를 프로젝트에 추가하고 해당 인터페이스를 구현하십시오 (기존 구현을 예로 참조하십시오).
패키지에 포함시키기 위해 변경 사항이있는 PR을 열어주십시오!