fix[cache]: fixed a bug where expired data could not be deleted

This commit is contained in:
luca
2024-08-16 15:37:43 +08:00
parent 2c66183b5e
commit 4513074778
@@ -85,6 +85,9 @@ public class LazyCache<K, V> {
var cacheValue = new CacheValue<V>();
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);