EHCache and Railo 3.1.2

Donnerstag, 19. November 2009

One of the things I like about working at CONTENS is that we do a lot of work on the technical side of the platform just thinking up ways to improve overall performance. Caching and the ability to Cluster naturally plays an important role.
We support several different caching mechanisms in CONTENS but when in a clustering environment a distributed/replicated cache across cluster nodes is definitely something you need consider. Enter EHCache and the Railo Team
If you have been paying attention and updating your Railo Development machine you would have noticed that the new Caching menu went from (Experimental) to (Beta) when Railo went to version 3.1.2.
Setting up distributed EHCache is relatively easy, you simply need 2 or more Railo Servers. You first need to create a new Cache connection and Choose "EHCache" instead of RamCache, give your Connection a Name and click Create. On the next screen you can tinker with the settings in the first block or just leave them the way they are (best to leave them alone).
Change the settings in the Distributed area (screenshot below) from Off to Manual, you can choose automatic and EHCache will find its own members with the same cache name but I think its better to go manual.

Once you have switched the Cache distribution from Off to Manual you can then insert members in the Manual block, and set up the host in the Listener portion (see screenshot). What is important here is how the Cache members are defined.
//<dns name or ip>:<port>/<cachename>
In the EHCache docs they suggest starting at port 40000 and going up from there for each member (warning: Each member MUST have unique port).

Once you have done that you can start using EHCache for your caching needs. How exactly you use EHCache in your code will be in another blog post soon.