Skip to content

Commit

Permalink
Revert "Lock timeout optimization"
Browse files Browse the repository at this point in the history
This reverts commit 495106f.
  • Loading branch information
jodydonetti committed Jan 16, 2022
1 parent 495106f commit 5716a32
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
25 changes: 1 addition & 24 deletions src/ZiggyCreatures.FusionCache/FusionCache_Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,7 @@ public partial class FusionCache
IFusionCacheEntry? entry;

// LOCK
var lto = options.LockTimeout;
if (lto == Timeout.InfiniteTimeSpan && memoryEntry is object && options.IsFailSafeEnabled && options.FactorySoftTimeout != Timeout.InfiniteTimeSpan)
{
// IF THERE IS NO SPECIFIC LOCK TIMEOUT
// + THERE IS A FALLBACK ENTRY
// + FAILSAFE IS ENABLED
// + THERE IS A FACTORY SOFT TIMEOUT
// --> USE IT AS A LOCK TIMEOUT
lto = options.FactorySoftTimeout;
}
var lockObj = await _reactor.AcquireLockAsync(key, operationId, lto, _logger, token).ConfigureAwait(false);

if (lockObj is null && memoryEntry is object)
{
// IF THE LOCK HAS NOT BEEN ACQUIRED
// + THERE IS A FALLBACK ENTRY
// --> USE IT (WITHOUT SAVING IT, SINCE THE ALREADY RUNNING FACTORY WILL DO IT ANYWAY)

// EVENT
_events.OnHit(operationId, key, memoryEntryIsValid == false);

return memoryEntry;
}

var lockObj = await _reactor.AcquireLockAsync(key, operationId, options.LockTimeout, _logger, token).ConfigureAwait(false);
bool isStale;
bool factoryCompletedSuccessfully = false;

Expand Down
23 changes: 0 additions & 23 deletions src/ZiggyCreatures.FusionCache/FusionCache_Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,7 @@ public partial class FusionCache
IFusionCacheEntry? entry;

// LOCK
var lto = options.LockTimeout;
if (lto == Timeout.InfiniteTimeSpan && memoryEntry is object && options.IsFailSafeEnabled && options.FactorySoftTimeout != Timeout.InfiniteTimeSpan)
{
// IF THERE IS NO SPECIFIC LOCK TIMEOUT
// + THERE IS A FALLBACK ENTRY
// + FAILSAFE IS ENABLED
// + THERE IS A FACTORY SOFT TIMEOUT
// --> USE IT AS A LOCK TIMEOUT
lto = options.FactorySoftTimeout;
}
var lockObj = _reactor.AcquireLock(key, operationId, options.LockTimeout, _logger);

if (lockObj is null && memoryEntry is object)
{
// IF THE LOCK HAS NOT BEEN ACQUIRED
// + THERE IS A FALLBACK ENTRY
// --> USE IT (WITHOUT SAVING IT, SINCE THE ALREADY RUNNING FACTORY WILL DO IT ANYWAY)

// EVENT
_events.OnHit(operationId, key, memoryEntryIsValid == false);

return memoryEntry;
}

bool isStale;
bool factoryCompletedSuccessfully = false;

Expand Down

0 comments on commit 5716a32

Please sign in to comment.