If you use EhCache and you have several applications in clusters, you will have to use a mechanism (JMS, JGroups, ...) to replicate the data cache.
One thing you should be aware of is that if you have another application that is not running in Java, the application will not be notified: JGroups are available only in Java, and your application, other than Java, will not be able to invalidate the organization’s caching. EhCache / Jgroups support allows you to configure replication in ONE configuration file (no additional code required!)
It seems that you are looking for the EhCache Update Through Copy feature. Let me point out one of the configuration options for EhCache:
Update via copy and invalidation
Update via copy : data sent to all nodes
Pros: Avoid a complete cache reload
Cons: Unrelated data between nodes is possible and useless if the TTL of cached data is low
Update using invalidation . Invalidation notification sent to all nodes. If the data is already cached, the nodes again delete the cached data request.
Pros: data consistency and easier network traffic
Cons: a lot of database queries, and this can lead to massive data demand at the same time.
Async vs sync
Asynchronous
Pros: fast response and data transfer
Cons: UDP ...
Synchronize
Pros: data integrity
Cons: Perf ...
Hope this helps you choose the right solution.
source share