Merge pull request #130 from LucaLq/main

fix[cache]: fixed a bug where expired data could not be deleted
This commit is contained in:
godotg
2024-08-16 16:06:56 +08:00
committed by GitHub
@@ -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);