=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -8,6 +8,7 @@ namespace adas_core.Application.Services.Caching
|
||||
/// Se basa en SemaphoreSlim y solo controla concurrencia DENTRO del proceso.
|
||||
/// Para CacheService (in-memory).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ea44018 -->
|
||||
public class InMemoryLockProvider : ILockProvider
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, SemaphoreSlim> _locks = new(StringComparer.Ordinal);
|
||||
@@ -15,6 +16,7 @@ namespace adas_core.Application.Services.Caching
|
||||
/// <summary>
|
||||
/// Crea u obtiene un semáforo asociado a la clave.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=af8b85d body=29079e4 -->
|
||||
private SemaphoreSlim GetOrCreate(string key)
|
||||
{
|
||||
return _locks.GetOrAdd(key, _ => new SemaphoreSlim(1, 1));
|
||||
@@ -23,6 +25,12 @@ namespace adas_core.Application.Services.Caching
|
||||
/// <summary>
|
||||
/// Intenta adquirir el lock por clave.
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
|
||||
/// "Parameter 'key' is not documented" -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
|
||||
/// "Parameter 'timeout' is not documented" -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=missing_returns
|
||||
/// "Return value (bool indicating acquisition success) is not documented" -->
|
||||
public async Task<bool> AcquireAsync(string key, TimeSpan timeout)
|
||||
{
|
||||
var sem = GetOrCreate(key);
|
||||
@@ -42,6 +50,8 @@ namespace adas_core.Application.Services.Caching
|
||||
/// <summary>
|
||||
/// Libera el lock (si existe y no está ya liberado).
|
||||
/// </summary>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
|
||||
/// "The 'key' parameter is not documented; only a <summary> is provided, with no <param name=\"key\"> tag describing the lock identifier." -->
|
||||
public Task ReleaseAsync(string key)
|
||||
{
|
||||
if (!_locks.TryGetValue(key, out var sem))
|
||||
|
||||
Reference in New Issue
Block a user