Caffeine Cache
Store, get and invalidate entries in a local Caffeine cache.
What’s inside
-
Caffeine Cache component, URI syntax:
caffeine-cache:cacheName -
Caffeine LoadCache component, URI syntax:
caffeine-loadcache:cacheName
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-caffeine-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
The starter supports 34 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.caffeine-cache.action | The action to perform when the message has no CamelCaffeineAction header. When neither sets an action, the exchange fails. | String | |
camel.component.caffeine-cache.autowired-enabled | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | Boolean |
camel.component.caffeine-cache.cache-loader | The Caffeine CacheLoader that loads the value of a key that is not in the cache, for the GET and GET_ALL actions. Only used by caffeine-loadcache, which needs it to create the cache. The option is a com.github.benmanes.caffeine.cache.CacheLoader type. | CacheLoader | |
camel.component.caffeine-cache.configuration | The shared configuration that each endpoint of this component starts from; the options of the endpoint override it. The option is a org.apache.camel.component.caffeine.CaffeineConfiguration type. | CaffeineConfiguration | |
camel.component.caffeine-cache.create-cache-if-not-exist | Whether the component creates the cache when the registry has no cache bean with the cache name. The component keeps the caches it creates by name, so the endpoints with the same cache name share one cache, which the options of the first of these endpoints to start configure. The cache options (evictionType, maximumSize and the others) only apply to a cache that the component creates. When false and the registry has no such bean, the endpoint fails to start. | true | Boolean |
camel.component.caffeine-cache.enabled | Whether to enable auto configuration of the caffeine-cache component. This is enabled by default. | Boolean | |
camel.component.caffeine-cache.eviction-type | Which options configure the eviction of the cache: SIZE_BASED uses initialCapacity and maximumSize, and TIME_BASED uses expireAfterAccessTime and expireAfterWriteTime. The options of the other type are ignored. | size-based | EvictionType |
camel.component.caffeine-cache.expire-after-access-time | The time in seconds after the last read or write of an entry, or its creation, after which Caffeine removes the entry from the cache (Caffeine expireAfterAccess). With 0, entries expire right away. Only used when evictionType is TIME_BASED, together with expireAfterWriteTime: an entry expires at the first of the two times. | 300 | Integer |
camel.component.caffeine-cache.expire-after-write-time | The time in seconds after the creation of an entry, or the last replacement of its value, after which Caffeine removes the entry from the cache (Caffeine expireAfterWrite). With 0, entries expire right away. Only used when evictionType is TIME_BASED, together with expireAfterAccessTime: an entry expires at the first of the two times. | 300 | Integer |
camel.component.caffeine-cache.initial-capacity | The minimum total size of the internal data structures of the cache (Caffeine initialCapacity). A large enough estimate avoids resizing later, but a too large value wastes memory. Only used when evictionType is SIZE_BASED; when not set, Caffeine uses its default. | Integer | |
camel.component.caffeine-cache.key | The key of the entry for the GET, PUT and INVALIDATE actions when the message has no CamelCaffeineKey header. When neither sets a key, these actions fail. | String | |
camel.component.caffeine-cache.lazy-start-producer | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | Boolean |
camel.component.caffeine-cache.maximum-size | The maximum number of entries the cache may contain (Caffeine maximumSize). As the size grows close to the maximum, Caffeine evicts the entries that are less likely to be used again, and it may evict an entry before the limit is exceeded or exceed it for a short time while evicting. With 0, Caffeine evicts each entry right after it is stored. Only used when evictionType is SIZE_BASED; when not set, the size of the cache has no limit. | Integer | |
camel.component.caffeine-cache.removal-listener | A Caffeine RemovalListener that the cache notifies each time an entry is removed, whether it was invalidated, replaced, evicted or expired. Caffeine calls it asynchronously after the removal, and only logs the exceptions it throws. The option is a com.github.benmanes.caffeine.cache.RemovalListener type. | RemovalListener | |
camel.component.caffeine-cache.stats-counter | A Caffeine StatsCounter that records the statistics of the cache instead of the default counter of Caffeine. Only used when statsEnabled is true. The option is a com.github.benmanes.caffeine.cache.stats.StatsCounter type. | StatsCounter | |
camel.component.caffeine-cache.stats-enabled | Whether the cache records statistics (Caffeine recordStats), such as the hit and miss counts that Cache.stats() returns. Recording them costs some performance on each cache operation. | false | Boolean |
camel.component.caffeine-cache.value-type | The fully qualified class name of the type that the PUT action converts the message body to before it stores it as the value. When not set, the body is stored as it is. Not used when the CamelCaffeineValue header gives the value. | String | |
camel.component.caffeine-loadcache.action | The action to perform when the message has no CamelCaffeineAction header. When neither sets an action, the exchange fails. | String | |
camel.component.caffeine-loadcache.autowired-enabled | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | Boolean |
camel.component.caffeine-loadcache.cache-loader | The Caffeine CacheLoader that loads the value of a key that is not in the cache, for the GET and GET_ALL actions. Only used by caffeine-loadcache, which needs it to create the cache. The option is a com.github.benmanes.caffeine.cache.CacheLoader type. | CacheLoader | |
camel.component.caffeine-loadcache.configuration | The shared configuration that each endpoint of this component starts from; the options of the endpoint override it. The option is a org.apache.camel.component.caffeine.CaffeineConfiguration type. | CaffeineConfiguration | |
camel.component.caffeine-loadcache.create-cache-if-not-exist | Whether the component creates the cache when the registry has no cache bean with the cache name. The component keeps the caches it creates by name, so the endpoints with the same cache name share one cache, which the options of the first of these endpoints to start configure. The cache options (evictionType, maximumSize and the others) only apply to a cache that the component creates. When false and the registry has no such bean, the endpoint fails to start. | true | Boolean |
camel.component.caffeine-loadcache.enabled | Whether to enable auto configuration of the caffeine-loadcache component. This is enabled by default. | Boolean | |
camel.component.caffeine-loadcache.eviction-type | Which options configure the eviction of the cache: SIZE_BASED uses initialCapacity and maximumSize, and TIME_BASED uses expireAfterAccessTime and expireAfterWriteTime. The options of the other type are ignored. | size-based | EvictionType |
camel.component.caffeine-loadcache.expire-after-access-time | The time in seconds after the last read or write of an entry, or its creation, after which Caffeine removes the entry from the cache (Caffeine expireAfterAccess). With 0, entries expire right away. Only used when evictionType is TIME_BASED, together with expireAfterWriteTime: an entry expires at the first of the two times. | 300 | Integer |
camel.component.caffeine-loadcache.expire-after-write-time | The time in seconds after the creation of an entry, or the last replacement of its value, after which Caffeine removes the entry from the cache (Caffeine expireAfterWrite). With 0, entries expire right away. Only used when evictionType is TIME_BASED, together with expireAfterAccessTime: an entry expires at the first of the two times. | 300 | Integer |
camel.component.caffeine-loadcache.initial-capacity | The minimum total size of the internal data structures of the cache (Caffeine initialCapacity). A large enough estimate avoids resizing later, but a too large value wastes memory. Only used when evictionType is SIZE_BASED; when not set, Caffeine uses its default. | Integer | |
camel.component.caffeine-loadcache.key | The key of the entry for the GET, PUT and INVALIDATE actions when the message has no CamelCaffeineKey header. When neither sets a key, these actions fail. | String | |
camel.component.caffeine-loadcache.lazy-start-producer | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | Boolean |
camel.component.caffeine-loadcache.maximum-size | The maximum number of entries the cache may contain (Caffeine maximumSize). As the size grows close to the maximum, Caffeine evicts the entries that are less likely to be used again, and it may evict an entry before the limit is exceeded or exceed it for a short time while evicting. With 0, Caffeine evicts each entry right after it is stored. Only used when evictionType is SIZE_BASED; when not set, the size of the cache has no limit. | Integer | |
camel.component.caffeine-loadcache.removal-listener | A Caffeine RemovalListener that the cache notifies each time an entry is removed, whether it was invalidated, replaced, evicted or expired. Caffeine calls it asynchronously after the removal, and only logs the exceptions it throws. The option is a com.github.benmanes.caffeine.cache.RemovalListener type. | RemovalListener | |
camel.component.caffeine-loadcache.stats-counter | A Caffeine StatsCounter that records the statistics of the cache instead of the default counter of Caffeine. Only used when statsEnabled is true. The option is a com.github.benmanes.caffeine.cache.stats.StatsCounter type. | StatsCounter | |
camel.component.caffeine-loadcache.stats-enabled | Whether the cache records statistics (Caffeine recordStats), such as the hit and miss counts that Cache.stats() returns. Recording them costs some performance on each cache operation. | false | Boolean |
camel.component.caffeine-loadcache.value-type | The fully qualified class name of the type that the PUT action converts the message body to before it stores it as the value. When not set, the body is stored as it is. Not used when the CamelCaffeineValue header gives the value. | String |