From c4812dcad7e4ca222e91b42177995d6bac286023 Mon Sep 17 00:00:00 2001 From: godotg Date: Wed, 27 Mar 2024 16:27:49 +0800 Subject: [PATCH] perf[cache]: checkMaxSize need currentTimeMillis method for precise time --- .../src/main/java/com/zfoo/scheduler/util/LazyCache.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java b/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java index 87851212d..855af9b6a 100644 --- a/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java +++ b/scheduler/src/main/java/com/zfoo/scheduler/util/LazyCache.java @@ -16,7 +16,7 @@ public class LazyCache { private static final float DEFAULT_BACK_PRESSURE_FACTOR = 0.11f; - private static final long MILLIS_MAX_SIZE_CHECK_INTERVAL = 300; + private static final long MILLIS_MAX_SIZE_CHECK_INTERVAL = 13; private static class CacheValue { public volatile V value; @@ -134,7 +134,7 @@ public int size() { // ----------------------------------------------------------------------------------------------------------------- private void checkMaximumSize() { if (cacheMap.size() > backPressureSize) { - var now = TimeUtils.now(); + var now = TimeUtils.currentTimeMillis(); var sizeCheckTime = sizeCheckTimeAtomic.get(); if (now > sizeCheckTime) { if (sizeCheckTimeAtomic.compareAndSet(sizeCheckTime, now + MILLIS_MAX_SIZE_CHECK_INTERVAL)) {