Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,19 @@ internal void SetEntry(CacheEntry entry)
priorEntry.SetExpired(EvictionReason.Replaced);
}

bool exceedsCapacity = UpdateCacheSizeExceedsCapacity(entry);
if (entry.CheckExpired(utcNow))
{
entry.InvokeEvictionCallbacks();
if (priorEntry != null)
{
RemoveEntry(priorEntry);
}
StartScanForExpiredItemsIfNeeded(utcNow);
return;
}

if (!entry.CheckExpired(utcNow) && !exceedsCapacity)
bool exceedsCapacity = UpdateCacheSizeExceedsCapacity(entry);
if (!exceedsCapacity)
{
bool entryAdded = false;

Expand Down Expand Up @@ -192,22 +202,8 @@ internal void SetEntry(CacheEntry entry)
}
else
{
if (exceedsCapacity)
{
// The entry was not added due to overcapacity
entry.SetExpired(EvictionReason.Capacity);

TriggerOvercapacityCompaction();
}
else
{
if (_options.SizeLimit.HasValue)
{
// Entry could not be added due to being expired, reset cache size
Interlocked.Add(ref _cacheSize, -entry.Size.Value);
}
}

entry.SetExpired(EvictionReason.Capacity);
TriggerOvercapacityCompaction();
entry.InvokeEvictionCallbacks();
if (priorEntry != null)
{
Expand Down