News: Ehcache 1.0 released
ehcache 1.0 has been released. Ehcache is a small, fast and simple in-process Java cache, available under an open source license.
Ehcache is now one year old. In that time it has moved it has been incorporated into many projects and commercial software offerings including Hibernate, Spring, Apache Cocoon, Apache Turbine, Confluence and many others.
It has both memory and disk stores. They are are scalable to hundreds of caches and gigabytes of storage. It is fully documented, has high test and has high test coverage.
Ehcache deliberately emphasizes simplicity, safety and scalability over features. As such it is a departure from other efforts which seek to implement JSR107.
Caching is a great way to speed up applications. Ehcache comes with extensive documentation on how to apply it to common problems such as Hibernate, web pages and search engines.
Ehcache can be used in J2SE and J2EE. It works with JDK1.2 through to JDK5.
- Can this be better than using the session? by Zviki Cohen on October 12 2004 02:27 EDT
- Can we compare EHCache with OSCache? by Nitin Tiwari on January 10 2005 00:26 EST
Suppose I have the option to replace all my HttpSession access with such a cache. Can this provide any performance gain?
Does anyone has any experience with that?
I take it you mean storing things in the session and then picking them up on the next request.
Using a cache gives you the advantage that multiple request threads can access the values in the cache, whereas session scope is limited to the next request in that session. Of course you could also use application scope.
I don't use caching to replace that however. There seems to be a number of sweet spots in web apps: caching whole pages or page fragments, caching 'result sets' of value or domain objects, and utilising Hibernate caches.
Ehcache acts as the default plugin for Hibernate.
It contains constructs with documented examples for caching 'result sets' of value objects or domain objects.
The BlockingCache is used for caching pages and page fragments. I currently use this from a PageCacheFilter and a PageFragmentFilter. This is such a common use that I plan to add these classes to the constructs package of ehcache.
Suppose I have the option to replace all my HttpSession access with such a cache. Can this provide any performance gain?Does anyone has any experience with that?
WebLogic Server has several ways of caching (read persisting) the user session like JDBC and File System which can achieve just what you want! Performance wise, I don't think because it increases the number of disk IO and/or network traffic. But looking at scalability a big YES. You are no longer limited to the amount of physical memory ($$$) available. Again, it depends upon your server configuration, network and I/O speed, network traffic, blah blah. In some cases increasing your server's physical memory may prove more feasible than providing an efficient alternative.
Can I get a Comparison ( Features and performance wise) of EHCache with OSCache.
I am currently in an impression that OSCache can cache portions of JSP pages, which is nowhere documented in the case of EHCache.
Also, I want a suggestion on which caching technique should i use, if I am not using Hibernate?
My Object caching requirement can be both, in-memory and presistent.
Please suggest the better option for me, along with the Comparison.
Thanks and regards,
You can mix them.
From OSCache, use all the classes from com.opensymphony.oscache.web.filter, and from ehcache, use it all. All you have to do is adapt the CacheFilter class a bit.
EHCache is great, but I find no trace of the "concurrent" library (or the equivalent in Java 5). When you use a LinkedHashMap, a get() modifies the Map by changing the order of the elements, so it has to be totally synchronized.
I just found where the concurrent was used (ehcache-constructs).
Your post came out, right when I had already decided to go for EHCache along with Hibernate. I'll see if I can correlate the two, and get the Best solution.