Google for "Java distributed cache" and find some solutions. The Apache JCS is one. There is a JSR in progress to put a distributed cache into the JDK or J2EE or somewhere, but it hasn't made much progress in recent years.
I think the most common approach is to broadcast a message any time a cached entry is changed using JMS or RMI or sockets or whatever for the message. The other caches in the cluster mark the key invalid so they are forced to retrieve the value from a common store next time somebody asks for it.
The system I'm using synchronizes values in memory across a cluster but they are not backed up by a database or any external persistent store. So they have to send the actual value any time one cache is updated. And I'm not sure how they bring a server that joins the cluster late up to date.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
The shortest definition I can think of for a cluster is "multiple independent processing systems tied to common storage."
There are two general models for clustering. In the Sun environment we've referred to them as HA (high availability) and HPC (high performance computing). Physically, these models are the same, so it's all about what information passes between two or more clustered machines.
In HA clusters, it's pretty simple. Each system wants to know if the other systems are working properly or not. They use the connection between them to determine if the current membership is valid. If not, they attempt to lock out down or failing systems to preserve the whole, and failover applications on the sickie machine to a healthy one. Access to a storage component is 'either-or' based on disk ownership.
In HPC clusters, the goal is to have machines working as an aggregate of processing power (what Oracle calls a 'parallel server' is the same idea). Access to common storage is negotiated by passing tokens between the systems that represent ownership of storage. Access to storage is 'either-or' based on token ownership.
In both cases, however, external storage is the fail-safe element of a failing system. Physical memory is not, unless it's backed by disk storage that another cluster member can access. In other words, it doesn't matter what kind of object you have in memory, unless the cache that contains it is saved to and retrievable from shared storage. [ September 12, 2005: Message edited by: Michael Ernest ]
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth