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

Replace Values with KeyValuePair enumerator in MemoryCache #53762

Merged
merged 4 commits into from
Jun 10, 2021
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 @@ -316,8 +316,11 @@ void ScheduleTask(DateTimeOffset utcNow)
private static void ScanForExpiredItems(MemoryCache cache)
{
DateTimeOffset now = cache._lastExpirationScan = cache._options.Clock.UtcNow;
foreach (CacheEntry entry in cache._entries.Values)
ezgambac marked this conversation as resolved.
Show resolved Hide resolved

foreach (KeyValuePair<object, CacheEntry> item in cache._entries)
{
CacheEntry entry = item.Value;

ezgambac marked this conversation as resolved.
Show resolved Hide resolved
if (entry.CheckExpired(now))
{
cache.RemoveEntry(entry);
Expand Down Expand Up @@ -399,8 +402,9 @@ private void Compact(long removalSizeTarget, Func<CacheEntry, long> computeEntry

// Sort items by expired & priority status
DateTimeOffset now = _options.Clock.UtcNow;
foreach (CacheEntry entry in _entries.Values)
foreach (KeyValuePair<object, CacheEntry> item in _entries)
{
CacheEntry entry = item.Value;
ezgambac marked this conversation as resolved.
Show resolved Hide resolved
if (entry.CheckExpired(now))
{
entriesToRemove.Add(entry);
Expand Down