-
I have a issue with caffein. I use AsyncCache: var caffeine = Caffeine.newBuilder()
.maximumSize(maximumSize)
.expireAfter(new Expiry<String, CachingMsg>() {
@Override
public long expireAfterCreate(String key, CachingMsg value, long currentTime) {
var seconds = (value.getExpireTime() - System.currentTimeMillis()) / 1000L;
return TimeUnit.SECONDS.toNanos(Math.max(seconds, 0));
}
@Override
public long expireAfterUpdate(String key, CachingMsg value, long currentTime, @NonNegative long currentDuration) {
var seconds = (value.getExpireTime() - System.currentTimeMillis()) / 1000L;
return TimeUnit.SECONDS.toNanos(Math.max(seconds, 0));
}
@Override
public long expireAfterRead(String key, CachingMsg value, long currentTime, @NonNegative long currentDuration) {
return currentDuration;
}
})
.recordStats()
.scheduler(Scheduler.systemScheduler())
.removalListener((key, value, cause) -> log.info(null,String.format("%s: key %s of mainKey %s", cause, key, mainKey))) Data i save in cache : "{"status":"1","lastUpdate":1667883430507}" |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
What is the problem? At 2M entries that is 750 bytes per, which seems reasonable. It sounds like you oversized if that is too much |
Beta Was this translation helpful? Give feedback.
-
I dump memory usage in local : I see class java.util.concurrent.ConcurrentHashMap exist in memory. Whether it task my memory ??. Pls team sp me. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I cannot help from that information. I don't know your system, the eviction and cache sizes seem stable, and there isn't anything to indicate a change needed to this library. Depending on your JDK version, only the most recent will return memory once allocated so it is unclear if that is why it stays high (heap vs system allocated). Usually it takes a combination of logs, heap dumps, and JFR snapshots to figure these types of application problems. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Sorry for bothering you, i wanna ask u new question. |
Beta Was this translation helpful? Give feedback.
What is the problem? At 2M entries that is 750 bytes per, which seems reasonable. It sounds like you oversized if that is too much