« Back to Caching...

Caching (EhCache)

Introduction#

Starting with Liferay 4.3.1 Caching (OSCache) has been replaced by Ehcache. There were a few motivations, initially inspired by a blog entry from community member Mika Koivisto:

"After using the new ehcache and its replication feature I’m convinced thats the caching solution that should be used over OSCache especially after seeing a benchmark where it kicked the crap out of OSCache."

  1. Ehcache provides better performance. See http://gregluck.com/blog/archives/2006/03/comparative_cac.html
  2. Ehcache has advanced replication features See [http://ehcache.sourceforge.net
  3. |Ehcache clustering options is more robust. See http://ehcache.sourceforge.net]
  4. The BlockingCache uses mutexes to reduce contention.
  5. Terracotta supports Ehcacheout of the box. Liferay will integrate closely with Terracotta DSO for increased scalability and performance.
  6. Ehcache has much broader support. The fact that Gavin King (from the Hibernate project) is a committer gives Ehcache much credibility.
  7. Fine grained configuration for multiple caches. The ability to tune specific cache settings for each object type provides greater flexibility.

Known Limitations:

  1. Ehcache does not directly support the concept of cache groups to manage dependent objects, so a custom solution was engineered to support this concept.

Migrating from OSCache (pre 4.3.1) to EhCache#

The following properties were removed from portal.properties:

 cache.memory=true
 cache.capacity=10000
 cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
 cache.blocking=true
 cache.event.listeners=...
 cache.cluster.multicast.ip=231.12.21.100
 cache.cluster.properties=...

Additionally, the following files were removed from portal-impl.jar:

 cache-multi-vm.properties
 cache-single-vm.properties

Any custom settings you have configured in these properties or files need to be translated to the Ehcache configuration described below.

Ehcache Configuration#

The following section describes Ehcache configuration as it pertains to Liferay. For specific configuration consult the Ehcache documentation.

The following properties have been added to portal.properties:

    #
    # Set the Hibernate cache provider. Ehcache is recommended in a clustered
    # environment. See hibernate.cache.provider_configuration_file_resource_path
    # for detailed configuration.
    #
    hibernate.cache.provider_class=net.sf.ehcache.hibernate.EhCacheProvider
    #
    # This property is used if Hibernate is configured to use Ehcache's
    # cache provider.
    #
    net.sf.ehcache.configurationResourceName=/ehcache/hibernate.xml
    #
    # Set the classpath to the location of the Ehcache config file for internal
    # caches. Edit the file specified in the property
    # "ehcache.multi-vm.config.location" to enable clustered cache.
    #
    ehcache.single.vm.config.location=/ehcache/liferay-single-vm.xml
    ehcache.multi.vm.config.location=/ehcache/liferay-multi-vm.xml

The following files have been added to portal-impl.jar. These are used to control specific Ehcache settings:

 /ehcache/hibernate.xml

Used for hibernate specific caches. These can be distributed but has been disabled by default.

 /ehcache/liferay-single-vm.xml

Used for caches not intended for clustering. Do not try to cluster these caches.

 /ehcache/liferay-multi-vm.xml

Used for caches that may be distributed. Clustering has been disabled by default.

0 Attachments
17346 Views
Average (1 Vote)
Comments

Showing 0 Comments