diff --git a/dotCMS/src/main/java/com/dotmarketing/business/cache/provider/caffine/CaffineCache.java b/dotCMS/src/main/java/com/dotmarketing/business/cache/provider/caffine/CaffineCache.java index fe149aaec3b2..d3734a57664e 100644 --- a/dotCMS/src/main/java/com/dotmarketing/business/cache/provider/caffine/CaffineCache.java +++ b/dotCMS/src/main/java/com/dotmarketing/business/cache/provider/caffine/CaffineCache.java @@ -31,6 +31,7 @@ * i.e., for the "graphqlquerycache" group *

* cache.graphqlquerycache.chain=com.dotmarketing.business.cache.provider.caffine.CaffineCache + * cache.graphqlquerycache.size=10000 * cache.graphqlquerycache.seconds=15 */ public class CaffineCache extends CacheProvider { @@ -59,7 +60,9 @@ public boolean isDistributed() { @Override public void init() { - isInitialized.compareAndSet(false, doInit()); + if(!isInitialized.getAndSet(true)){ + doInit(); + }; } private boolean doInit() { @@ -116,8 +119,7 @@ public Object get(String group, String key) { if (group == null || key == null) { return null; } - DynamicTTLCache cache = getCache(group); - return cache.getIfPresent(key.toLowerCase()); + return getCache(group).getIfPresent(key.toLowerCase()); } @@ -128,15 +130,14 @@ public void remove(String group, String key) { return; } - DynamicTTLCache cache = getCache(group); // Invalidates from Cache a key from a given group - cache.invalidate(key.toLowerCase()); + getCache(group).invalidate(key.toLowerCase()); } @Override public void remove(String group) { Logger.debug(this.getClass(), "===== Calling remove for [" + getName() - + "] - " + cacheKey(group, "")); + + "] - " + group); if (group == null) { return; } @@ -150,8 +151,7 @@ public void removeAll() { @Override public Set getKeys(String group) { - DynamicTTLCache cache = getCache(group); - return cache.asMap().keySet(); + return getCache(group).asMap().keySet(); } @Override @@ -194,7 +194,7 @@ public CacheProviderStats getStats() { long millis = foundCache.defaultTTLInMillis; - String duration = millis == Long.MAX_VALUE ? "" : " / " + nf.format(millis / 1000) + "s"; + String duration = millis == Long.MAX_VALUE ? "" : " | ttl:" + nf.format(millis / 1000) + "s"; com.github.benmanes.caffeine.cache.stats.CacheStats cstats = foundCache.stats(); stats.addStat(CacheStats.REGION, group); @@ -226,9 +226,7 @@ public void shutdown() { isInitialized.set(false); } - private String cacheKey(String group, String key) { - return (group + ":" + key).toLowerCase(); - } + private DynamicTTLCache getCache(String cacheNameIn) { if (cacheNameIn == null) {