Skip to content

Commit

Permalink
fix[cache]: int overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Mar 27, 2024
1 parent 03d7996 commit fda2d6a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class LazyCache<K, V> {

private static final float DEFAULT_BACK_PRESSURE_FACTOR = 0.11f;
private static final float DEFAULT_BACK_PRESSURE_FACTOR = 0.13f;

private static class CacheValue<V> {
public volatile V value;
Expand Down Expand Up @@ -63,7 +63,7 @@ public static enum RemovalCause {

public LazyCache(int maximumSize, long expireAfterAccessMillis, long expireCheckIntervalMillis, BiConsumer<Pair<K, V>, RemovalCause> removeListener) {
this.maximumSize = maximumSize;
this.backPressureSize = maximumSize + (int) (maximumSize * DEFAULT_BACK_PRESSURE_FACTOR);
this.backPressureSize = Math.max(maximumSize, maximumSize + (int) (maximumSize * DEFAULT_BACK_PRESSURE_FACTOR));
this.expireAfterAccessMillis = expireAfterAccessMillis;
this.expireCheckIntervalMillis = expireCheckIntervalMillis;
this.minExpireTime = TimeUtils.now();
Expand Down

0 comments on commit fda2d6a

Please sign in to comment.