Joined: 10/01/2008 08:20:15
Mentawai uses JGroups (the best Java cluster solution?) to implement a distributed cache. This can be useful when you have many web servers in load balance and you want to accomplish seamless fail-over.
That's it! Just make sure the objects you place in the cache are serializable and all instances of your cache running in different machines will share the same data.
The default cache implementation is LRU (Least Resource Usage), so the least accessed entry will be removed when the cache gets full. You can also uso a FIFOCache (first in, first out, in other words, the oldest entry will be removed) like that:
If you are bringing a new web server into the load balance pool, keep in mind that it will first have to get all the entries from the cluster before it can start operating. This can take some time if the cache is too big.
Another option is to use the SynchronizedCache which just synchronizes new entries with the other nodes and does not have the startup overhead.