Skip to content

Commit

Permalink
Performance improvement for .NET 9.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Aug 11, 2024
1 parent 8ef13b7 commit 0bb3f89
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 66 deletions.
6 changes: 3 additions & 3 deletions bus/EasyCaching.Bus.Zookeeper/DefaultZookeeperBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class DefaultZookeeperBus : EasyCachingAbstractBus
/// <summary>
/// lock
/// </summary>
private readonly object _zkEventLock = new object();
private readonly Lock _zkEventLock = new Lock();

/// <summary>
/// The serializer.
Expand Down Expand Up @@ -214,7 +214,7 @@ private async Task SubscribeDataChange(WatchedEvent @event)
/// <returns></returns>
private async Task ReZkConnect()
{
if (!Monitor.TryEnter(_zkEventLock, _zkBusOptions.ConnectionTimeout))
if (!_zkEventLock.TryEnter(_zkBusOptions.ConnectionTimeout))
return;
try
{
Expand All @@ -234,7 +234,7 @@ private async Task ReZkConnect()
}
finally
{
Monitor.Exit(_zkEventLock);
_zkEventLock.Exit();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="../../build/version.props" />
<Import Project="../../build/releasenotes.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net9.0</TargetFrameworks>
<Owners>ncc;Catcher Wong</Owners>
<Authors>ncc;Catcher Wong</Authors>
<VersionPrefix>$(EasyCachingZookeeperBusPackageVersion)</VersionPrefix>
Expand Down
2 changes: 1 addition & 1 deletion src/EasyCaching.Core/DistributedLock/DistributedLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace EasyCaching.Core.DistributedLock
public class DistributedLock : MemoryLock
{
private readonly IDistributedLockProvider _provider;
private readonly object _syncObj = new object();
private readonly Lock _syncObj = new Lock();
private readonly DistributedLockOptions _options;
private readonly ILogger _logger;

Expand Down
2 changes: 1 addition & 1 deletion src/EasyCaching.Core/DistributedLock/MemoryLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MemoryLock : IDistributedLock

public string Key { get; }

private readonly object _syncObj = new object();
private readonly Lock _syncObj = new Lock();

public MemoryLock(string key) => Key = key;

Expand Down
59 changes: 0 additions & 59 deletions src/EasyCaching.Core/DistributedLock/RefCounter.cs

This file was deleted.

11 changes: 10 additions & 1 deletion src/EasyCaching.Core/EasyCaching.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<Import Project="../../build/version.props" />
<Import Project="../../build/releasenotes.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net9.0</TargetFrameworks>
<LangVersion>Preview</LangVersion>
<Owners>ncc;Catcher Wong</Owners>
<Authors>ncc;Catcher Wong</Authors>
<VersionPrefix>$(EasyCachingCorePackageVersion)</VersionPrefix>
Expand Down Expand Up @@ -36,12 +37,20 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.0" />
<PackageReference Include="Backport.System.Threading.Lock" Version="1.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Backport.System.Threading.Lock" Version="1.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 0bb3f89

Please sign in to comment.