163.5. 例子
使用自定义缓存容器从默认缓存中检索特定的密钥:
from("direct:start") .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.GET) .setHeader(InfinispanConstants.KEY).constant("123") .to("infinispan?cacheContainer=#cacheContainer");
从命名缓存检索特定密钥:
from("direct:start") .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.PUT) .setHeader(InfinispanConstants.KEY).constant("123") .to("infinispan:myCacheName");
使用 lifespan 生成一个值
from("direct:start") .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.GET) .setHeader(InfinispanConstants.KEY).constant("123") .setHeader(InfinispanConstants.LIFESPAN_TIME).constant(100L) .setHeader(InfinispanConstants.LIFESPAN_TIME_UNIT.constant(TimeUnit.MILLISECONDS.toString()) .to("infinispan:myCacheName");
使用带有额外参数(主机、端口和协议版本)的缓存容器配置从远程缓存检索特定密钥:
org.infinispan.client.hotrod.configuration.Configuration cacheContainerConfiguration = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServer() .host("localhost") .port(9999) .version(org.infinispan.client.hotrod.ProtocolVersion.PROTOCOL_VERSION_25) .build(); ... from("direct:start") .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.GET) .setHeader(InfinispanConstants.KEY).constant("123") .to("infinispan?cacheContainerConfiguration=#cacheContainerConfiguration");