Skip to content

Commit

Permalink
Merge pull request #130 from LucaLq/main
Browse files Browse the repository at this point in the history
fix[cache]: fixed a bug where expired data could not be deleted
  • Loading branch information
jaysunxiao authored Aug 16, 2024
2 parents 2c66183 + 4513074 commit c8839f1
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public void put(K key, V value) {
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);
Expand Down

0 comments on commit c8839f1

Please sign in to comment.