Skip to content

Commit bda7622

Browse files
author
Travis Whidden
committed
zzzprojects#764 - Move DefaultCleanupFrequency to internal static non generic class
1 parent a3aede1 commit bda7622

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
namespace System.Linq.Dynamic.Core.Util
66
{
7+
internal static class ThreadSafeSlidingCacheConstants
8+
{
9+
// Default cleanup frequency
10+
public static readonly TimeSpan DefaultCleanupFrequency = TimeSpan.FromMinutes(10);
11+
}
12+
713
internal class ThreadSafeSlidingCache<TKey, TValue> where TKey : notnull where TValue : notnull
814
{
9-
// ReSharper disable once StaticMemberInGenericType
10-
private static readonly TimeSpan _defaultCleanupFrequency = TimeSpan.FromMinutes(10);
1115
private readonly ConcurrentDictionary<TKey, (TValue Value, DateTime ExpirationTime)> _cache;
1216
private readonly TimeSpan _cleanupFrequency;
1317
private readonly IDateTimeUtils _dateTimeProvider;
@@ -37,7 +41,7 @@ public ThreadSafeSlidingCache(
3741
_cache = new ConcurrentDictionary<TKey, (TValue, DateTime)>();
3842
TimeToLive = timeToLive;
3943
_minCacheItemsBeforeCleanup = minCacheItemsBeforeCleanup;
40-
_cleanupFrequency = cleanupFrequency ?? _defaultCleanupFrequency;
44+
_cleanupFrequency = cleanupFrequency ?? ThreadSafeSlidingCacheConstants.DefaultCleanupFrequency;
4145
_deleteExpiredCachedItemsDelegate = Cleanup;
4246
_dateTimeProvider = dateTimeProvider ?? new DateTimeUtils();
4347
}

0 commit comments

Comments
 (0)