Terracotta3.1.1がリリースされたので試してみたら、EHCacheとの統合っぷりがすごい。
http://www.terracotta.org/web/display/orgsite/Get%20Started%20With%20Ehcache%20Distributed%20Cache に書いてる手順だけど、
- Terracottaサーバー立ち上げ
/bin/start-tc-server.bat - Tomcat(インストーラを使わずにzipかtar.gzを解凍してポートをずらしたやつ)を二つ立ち上げ
/bin/startup.bat, /bin/startup.bat - distributed-cache-sample.warを両方のTomcatのwebappsに配置
- http://localhost:8080/distributed-cache-sample/にアクセス
しただけでキャッシュが共有されてる!
tim-tomcatも入れてないし、dso-env.batを全然つかっとらんのに。すげー
設定はどこかと思ったら、 webapps/distributed-cache-sample/WEB-INF/classes/ehcache.xml に
<cache name="account-cache" maxElementsInMemory="10000" maxElementsOnDisk="1000" eternal="false" overflowToDisk="false" diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600" memoryStoreEvictionPolicy="LFU"> <terracotta /> </cache> <terracottaConfig url="localhost:9510"/>
って書かれてるだけだった。
なんか思い切ってるなあ。びっくりした。