I needed a memory-caching system in some of features, I wrote simple-caching system but it was too simple and can’t scale (distributed).
- J2EE servlet caching.
- General stuff (Programmatic APIs to cache things, even if it’s simple HashMap).
It was easy to setup EHCache. In some servlets, I was able to enable caching without touching servlet code:-
- Write filter classes, which extends from EHCache-construct classes
- Add cache entry and configuration in EHCache.xml
- Add entry of filter classes in web.xml
That’s it, caching is in place for simpler things but complex things and more control, I am going to use EHCache API.
Caching is important part of any web-application, one needs to think about it while designing the system. Some people might not agree and think it as premature optimization. I believe, if you know about requirements (scalebility or expected-user-count) then there is nothing wrong to think about optimization.
BTW! Do you think there is better option than EHCache? Please let me know. Thanks.