Discussions

News: Ehcache 1.0 released

  1. Ehcache 1.0 released (12 messages)

    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.

    Threaded Messages (12)

  2. Limiting Disk size?[ Go to top ]

    I read the docs, and it seems like a very easy and simple to use.
    I have one question regarding the cache size on the disk.
    I have read that "The DiskStore's size is unbounded". WHy cannot a limit parameter to this size be added?
  3. Limiting Disk size?[ Go to top ]

    There is an expiry thread which crawls through the disk store and deletes expired entries. Disk caches tend to grow and then steady state as the number of elements expiring match the number being added. Couple that with the very large size of modern hard disks and I see no practical reason to limit the size. The disk store scales well. It still works well at gigabyte sizes.
  4. Examples of ehcache[ Go to top ]

    Hi There,

      Do you have sample application (say on Tomcat) which uses ehcache ?

      What are the advantages of ehcache over homebuilt caches (which are customized to local requirements ?)

       why limit to the web layer ? why not the business tier ? has it been used for caching at the business tier ?

    Thank you,

    BR,
    ~A
  5. Examples of ehcache[ Go to top ]

    A sample application which uses ehcache is the Hibernate Object/Relational tool.

    There may be many great home-built caches out there. Ehcache started as one! The reason we did ehcache is probably also its major advantage. We were usng JCS which at the time was the default cache in Hibernate. On a 4 cpu server under heavy load we were seeing two problems: memory leaks and rarely, deadlocks. We patched it to fix the problems in the MemoryStore and then looked for a solution for the DiskStore. After testing several disk storage libraries we found problems with them too. We then decided to write our own. The whole ehcache represents about three person months of work. While a cache sounds really simple we have found that making it thread safe, fast and scalable are harder. We also did not want to be caught by any production bugs, so we went for 80% plus test coverage. Included in the tests are scalability and thread thrash tests which we used to break other solutions. On the scalability side we use Doug Lea's concurrency library which gives 10 times better concurrency scalability than simple synchornization. If you do roll your own, consider using some of our tests to test your cache.

    Ehcache is used mostly on our project by Hibernate in the data access area for Domain Object, Domain Object Collection and Query caches. Secondly it is used in the EJB tier for caching complex graphs of objects which are very expensive to generate. Finally it is used to cache web pages, web page fragments and binary files, including images. The hibernate package of ehcache works with Hibernate, and the constructs package has ready to use classes suitable for the business tier. I am planning to add servlet filters for the page caching. It is important to realise that these applications of ehcache are outside the core packages. More applications will be found and eventually these will probably be split out to a separate jar. See the documentation for examples of how to use ehcache with Hibernate and how to use the constructs package.
  6. business tier[ Go to top ]

    check out ehcache-constructs for business tier.

    and of course it works nicely with hibernate :)
  7. 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?
  8. 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.
  9. 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.

    Refer:
    http://e-docs.bea.com/wls/docs81/webapp/sessions.html#session-persistence
  10. Can we compare EHCache with OSCache?[ Go to top ]

    Hi,
    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,
    Nitin
  11. take the best of each[ Go to top ]

    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.

    Olivier Allouch
  12. found it[ Go to top ]

    I just found where the concurrent was used (ehcache-constructs).
  13. Thanks[ Go to top ]

    Thanks Olivier,
    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.

    Nitin