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);