Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Key-based hybrid/distributed locking#24210

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
MarkCiliaVincenti wants to merge3 commits intoabpframework:dev
base:dev
Choose a base branch
Loading
fromMarkCiliaVincenti:KeyBasedHybridLocking
Open
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Do the same for DistributedCache.
  • Loading branch information
@MarkCiliaVincenti
MarkCiliaVincenti committedNov 18, 2025
commitcdfccb0d865e18988ca13c393408d9e5a8daf40d
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsyncKeyedLock;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand DownExpand Up@@ -162,7 +163,7 @@ public class DistributedCache<TCacheItem, TCacheKey> : IDistributedCache<TCacheI

protected IUnitOfWorkManager UnitOfWorkManager { get; }

protectedSemaphoreSlim SyncSemaphore { get; }
protectedAsyncKeyedLocker<string> Locker { get; }

protected DistributedCacheEntryOptions DefaultCacheOptions = default!;

Expand All@@ -186,7 +187,7 @@ public DistributedCache(
ServiceScopeFactory = serviceScopeFactory;
UnitOfWorkManager = unitOfWorkManager;

SyncSemaphore = new SemaphoreSlim(1, 1);
Locker = new();

SetDefaultOptions();
}
Expand DownExpand Up@@ -534,7 +535,7 @@ await GetAsync(key, false, considerUow, token: token))
return value;
}

using (SyncSemaphore.Lock())
using (Locker.Lock(NormalizeKey(key)))
{
value = Get(key, hideErrors, considerUow);
if (value != null)
Expand DownExpand Up@@ -589,7 +590,7 @@ await GetAsync(key, false, considerUow, token: token))
return value;
}

using (awaitSyncSemaphore.LockAsync(token))
using (awaitLocker.LockAsync(NormalizeKey(key),token))
{
value = await GetAsync(key, hideErrors, considerUow, token);
if (value != null)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp