Browse Source

AsyncKeyedLock optimizations

pull/21305/head
Mark Cilia Vincenti 1 year ago
parent
commit
8e19724b3b
  1. 2
      Directory.Packages.props
  2. 9
      framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLock.cs

2
Directory.Packages.props

@ -6,7 +6,7 @@
<PackageVersion Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.0.0" />
<PackageVersion Include="aliyun-net-sdk-sts" Version="3.1.2" />
<PackageVersion Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
<PackageVersion Include="AsyncKeyedLock" Version="7.0.2" />
<PackageVersion Include="AsyncKeyedLock" Version="7.1.2" />
<PackageVersion Include="Autofac" Version="8.1.0" />
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="Autofac.Extras.DynamicProxy" Version="7.1.0" />

9
framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLock.cs

@ -30,12 +30,11 @@ public class LocalAbpDistributedLock : IAbpDistributedLock, ISingletonDependency
Check.NotNullOrWhiteSpace(name, nameof(name));
var key = DistributedLockKeyNormalizer.NormalizeKey(name);
var timeoutReleaser = await _localSyncObjects.LockAsync(key, timeout, cancellationToken);
if (!timeoutReleaser.EnteredSemaphore)
var timeoutReleaser = await _localSyncObjects.LockOrNullAsync(key, timeout, cancellationToken);
if (timeoutReleaser is not null)
{
timeoutReleaser.Dispose();
return null;
return new LocalAbpDistributedLockHandle(timeoutReleaser);
}
return new LocalAbpDistributedLockHandle(timeoutReleaser);
return null;
}
}

Loading…
Cancel
Save