Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement for .NET 9.0+ #545

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1.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.1.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
Loading