mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-12 18:17:02 +00:00
Merge pull request #130 from LucaLq/main
fix[cache]: fixed a bug where expired data could not be deleted
This commit is contained in:
1 file changed
+3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user