You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/09/19 10:20:57 UTC
[camel-k] 01/01: feat(examples): Add a Camel-caffeine Cache java
sample
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch caffeine-sample
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 20a4821a3aa7547353ef82651cf01f27b2a935fd
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 19 12:19:53 2018 +0200
feat(examples): Add a Camel-caffeine Cache java sample
---
runtime/examples/CaffeineCacheSample.java | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/runtime/examples/CaffeineCacheSample.java b/runtime/examples/CaffeineCacheSample.java
new file mode 100644
index 0000000..b417858
--- /dev/null
+++ b/runtime/examples/CaffeineCacheSample.java
@@ -0,0 +1,27 @@
+import org.apache.camel.builder.RouteBuilder;
+
+public class CaffeineCacheSample extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("timer:tick")
+ .setBody(constant("Hello"))
+ .setHeader("CamelCaffeineAction", constant("PUT"))
+ .setHeader("CamelCaffeineKey", constant("1"))
+ .toF("caffeine-cache://%s", "test")
+ .log("Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} is: ${body}")
+ .setBody(constant(null))
+ .setHeader("CamelCaffeineAction", constant("GET"))
+ .setHeader("CamelCaffeineKey", constant("1"))
+ .toF("caffeine-cache://%s", "test")
+ .log("Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} is: ${body}")
+ .setBody(constant(null))
+ .setHeader("CamelCaffeineAction", constant("INVALIDATE"))
+ .setHeader("CamelCaffeineKey", constant("1"))
+ .log("Invalidating entry with key ${header.CamelCaffeineKey}")
+ .toF("caffeine-cache://%s", "test")
+ .setHeader("CamelCaffeineAction", constant("GET"))
+ .setHeader("CamelCaffeineKey", constant("1"))
+ .toF("caffeine-cache://%s", "test")
+ .log("The Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey} has result? ${header.CamelCaffeineActionHasResult}");
+ }
+}