public static async Task <IDistributedLock> TryLockAsync( this IBlobStorage blobStorage, string container, string key, TimeSpan?lockDuration) { try { var leaseId = await blobStorage.AcquireLeaseAsync ( container : container, key : key, leaseTime : lockDuration ); return(new BlobLeaseBasedLock ( blobStorage: blobStorage, container: container, key: key, leaseId: leaseId, lockDuration: lockDuration )); } catch (StorageException e) when(e.RequestInformation.HttpStatusCode == StatusCodes.Status409Conflict) { return(null); } }
public async Task <string> AcquireLeaseAsync(string container, string key, TimeSpan?leaseTime, string proposedLeaseId = null) => await WrapAsync(async() => await _impl.AcquireLeaseAsync(container, key, leaseTime, proposedLeaseId), container);
public async Task <string> AcquireLeaseAsync(string container, string key, TimeSpan?leaseTime, string proposedLeaseId = null) => await _retryService.RetryAsync(async() => await _impl.AcquireLeaseAsync(container, key, leaseTime, proposedLeaseId), _onModificationsRetryCount);