Skip to content

Commit 579085e

Browse files
author
Travis Whidden
committed
zzzprojects#764 - Set cleanup time prior to enumeration to prevent multiple cleanup hits.
1 parent 3d09d49 commit 579085e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/System.Linq.Dynamic.Core/Parser/ThreadSafeSlidingCache.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ private void CleanupIfNeeded()
6666
{
6767
if (DateTime.UtcNow - _lastCleanupTime > _cleanupFrequency)
6868
{
69+
// Set here, so we don't have re-entry due to large collection enumeration.
70+
_lastCleanupTime = DateTime.UtcNow;
71+
6972
foreach (var key in _cache.Keys)
7073
{
7174
if (DateTime.UtcNow > _cache[key].ExpirationTime)
7275
{
7376
_cache.TryRemove(key, out _);
7477
}
7578
}
76-
_lastCleanupTime = DateTime.UtcNow;
79+
7780
}
7881
}
7982
}

0 commit comments

Comments
 (0)