Caching with a distributed map
Another use case for Cellar and camel-hazelcast
together is the implementation of a distributed cache solution.
The camel-hazelcast
component allows you to use a distributed map and execute different operations on this map.
As it's distributed, it means that the data is spread between different nodes: all nodes can see the same data (entries/values) from the distributed map. This means that you can share data between nodes.
In a Camel route, you can perform the following operations on the distributed map:
put
: To add new data in the mapdelete
: To remove data from the mapget
: To retrieve all data from the mapquery
: To retrieve particular data from the map
The operation type is defined in the CamelHazelcastOperationType
header.
For instance, we can implement a route that updates the cache with the following code:
<route> <from uri="direct-vm:add-in-cache"/> <setHeader headerName="CamelHazelcastOperationType"> <constant>put</constant...