From 45130747783c3b83d92a671083dac1ba54f4ad18 Mon Sep 17 00:00:00 2001 From: luca Date: Fri, 16 Aug 2024 15:37:43 +0800 Subject: [PATCH] fix[cache]: fixed a bug where expired data could not be deleted --- scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java b/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java index 3973a09ba..3858ffdba 100644 --- a/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java +++ b/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java @@ -85,6 +85,9 @@ public void put(K key, V value) { var cacheValue = new CacheValue(); cacheValue.value = value; cacheValue.expireTime = TimeUtils.now() + expireAfterAccessMillis; + if (cacheValue.expireTime < this.minExpireTime) { + this.minExpireTime = cacheValue.expireTime; + } var oldCacheValue = cacheMap.put(key, cacheValue); if (oldCacheValue != null) { removeListener.accept(List.of(new Pair<>(key, oldCacheValue.value)), RemovalCause.REPLACED);