Since Camel 2.20
Only producer is supported
The Caffeine Cache component enables you to perform caching operations using the simple cache from Caffeine.
Maven users will need to add the following dependency to
their pom.xml
for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-caffeine</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
caffeine-cache://cacheName[?options]
You can append query options to the URI in the following format: ?option=value&option=#beanRef&…
.
You can use your cache with the following code:
@BindToRegistry("cache")
Cache cache = Caffeine.newBuilder().recordStats().build();
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
from("direct://start")
.to("caffeine-cache://cache?action=PUT&key=1")
.to("caffeine-cache://cache?key=1&action=GET")
.log("Test! ${body}")
.to("mock:result");
}
};
}
In this way, you’ll work always on the same cache in the registry.
spring-boot:partial$starter.adoc