From 25be8c8a172ce316986c6feeb112e34f32ccb801 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Mon, 16 Sep 2024 14:05:53 -0500 Subject: [PATCH] Fix issue with checking cache item expiration --- src/Foundatio/Caching/InMemoryCacheClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Foundatio/Caching/InMemoryCacheClient.cs b/src/Foundatio/Caching/InMemoryCacheClient.cs index 73d4732b..1d746877 100644 --- a/src/Foundatio/Caching/InMemoryCacheClient.cs +++ b/src/Foundatio/Caching/InMemoryCacheClient.cs @@ -928,7 +928,7 @@ private async Task DoMaintenanceAsync() foreach (var kvp in _memory.ToArray()) { bool lastAccessTimeIsInfrequent = kvp.Value.LastAccessTicks < lastAccessMaximumTicks; - if (lastAccessTimeIsInfrequent && kvp.Value.ExpiresAt <= utcNow) + if (lastAccessTimeIsInfrequent && kvp.Value.ExpiresAt < DateTime.MaxValue && kvp.Value.ExpiresAt <= utcNow) { _logger.LogDebug("DoMaintenance: Removing expired key {Key}", kvp.Key); RemoveExpiredKey(kvp.Key);