You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/01/12 16:41:27 UTC

[GitHub] [camel] davsclaus commented on a change in pull request #6728: [CAMEL-17481] Caffeine cache improvements

davsclaus commented on a change in pull request #6728:
URL: https://github.com/apache/camel/pull/6728#discussion_r783248671



##########
File path: components/camel-caffeine/src/main/docs/caffeine-loadcache-component.adoc
##########
@@ -54,5 +54,13 @@ include::partial$component-endpoint-options.adoc[]
 // endpoint options: END
 
 
+== Cache invalidation
+
+Please note that before Camel 3.15 the invalidate all action (CaffeineConstants.ACTION_INVALIDATE_ALL) does not
+delete anything in case that CaffeineConstants.KEYS header is either missing or contains an empty set.
+
+Starting vom Camel 3.15 the invalidate all action does not delete anything in case the CaffeineConstants.KEYS header

Review comment:
       same here

##########
File path: components/camel-caffeine/src/main/java/org/apache/camel/component/caffeine/cache/CaffeineCacheEndpoint.java
##########
@@ -64,27 +64,37 @@ public Producer createProducer() throws Exception {
 
     @Override
     protected void doStart() throws Exception {
-        cache = CamelContextHelper.lookup(getCamelContext(), cacheName, Cache.class);
-        if (cache == null) {
-            Caffeine<?, ?> builder = Caffeine.newBuilder();
-            if (configuration.getEvictionType() == EvictionType.SIZE_BASED) {
-                builder.initialCapacity(configuration.getInitialCapacity());
-                builder.maximumSize(configuration.getMaximumSize());
-            } else if (configuration.getEvictionType() == EvictionType.TIME_BASED) {
-                builder.expireAfterAccess(configuration.getExpireAfterAccessTime(), TimeUnit.SECONDS);
-                builder.expireAfterWrite(configuration.getExpireAfterWriteTime(), TimeUnit.SECONDS);
-            }
-            if (configuration.isStatsEnabled()) {
-                if (ObjectHelper.isEmpty(configuration.getStatsCounter())) {
-                    builder.recordStats();
+
+        synchronized (this) {

Review comment:
       Is there a reason for using sync block here? A given endpoint instance is started only once and not concurrently

##########
File path: components/camel-caffeine/src/main/docs/caffeine-cache-component.adoc
##########
@@ -83,5 +83,13 @@ CaffeineConstants.ACTION_HAS_RESULT
 CaffeineConstants.ACTION_SUCCEEDED
 ------------------------------------------------------------
 
+== Cache invalidation
+
+Please note that before Camel 3.15 the invalidate all action (CaffeineConstants.ACTION_INVALIDATE_ALL) does not
+delete anything in case that CaffeineConstants.KEYS header is either missing or contains an empty set.
+
+Starting vom Camel 3.15 the invalidate all action does not delete anything in case the CaffeineConstants.KEYS header

Review comment:
       vom -> from




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org