Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Table of Contents

 

Rationale

 

The Magnolia cache module is based on EhCache, an open course Java distributed cache. We ship an ancient ehcache 1.5. This brings several drawbacks nowadays, among others performance, integration or scalability options. This page aims to evaluate possibilities of upgrading to the current 2.7 release. The task is logged as

Jira
serverMagnolia
keyMAGNOLIA-3535
. Ehcache is available under an Apache 2 license.

...

It requires Java 1.5 or 1.6 at runtime.

As such we can get rid of the backport-util imports in favour of java utils.

 

API changes

CacheManager

Creation of, access to, and removal of caches is controlled by the net.sf.ehcache.CacheManager. CacheManager supports two creation modes: singleton and instance.

Ehcache 1.5 allowed any number of CacheManagers with the same name (same configuration resource) to exist in a JVM. Therefore, each time new CacheManager(...) was called, a new CacheManager was created without regard to existing CacheManagers. info.magnolia.module.cache.ehcache.EhCacheFactory simply instantiates a new CacheManager on any module start.

Since Ehcache 2.5.2 the behavior of the CacheManager creation methods is as follows:

No Format
CacheManager.newInstance(Configuration configuration) – Create a new CacheManager or return the existing one named in the configuration.
CacheManager.create() – Create a new singleton CacheManager with default configuration, or return the existing singleton. This is the same as CacheManager.getInstance().
CacheManager.create(Configuration configuration) – Create a singleton CacheManager with the passed-in configuration, or return the existing singleton.
new CacheManager(Configuration configuration) – Create a new CacheManager, or throw an exception if the CacheManager named in the configuration already exists or if the parameter (configuration) is null.

...

The CacheManager's configuration source, an informative description of the source, preferably including the resource name and location, is not represented by a String anymore, but is abstracted by an encapsulating net.sf.ehcache.config.generator.ConfigurationSource class. It also doesn't substitute a CacheManager name (.setName(string) should be called for each CacheManager explicitely, while each name must be unique).

 

CacheConfigurationTransformer

...

An element is an atomic entry in a cache. There seem to be no changes on the API field since 1.5. Object based elements are used.

BlockingCache

 

The cache module already provides its own support for terminating stale requests and let them timed out. Moving to what ehcache comes with is perhaps not necessary at this point.
 

Other notes

...

  • changed meaning of maxElementsInMemory=0 for MemoryStore to be unlimited.
  • extended existing in-memory and on-disk concepts to include off-heap as an additional possible location.

...

EhCache change log

Git

There is a magnolia-4.5.x-MAGNOLIA-3535 branch created for this task.

  is available here|http://www.ehcache.org/changes-report], since then [it's listed here|https://jira.terracotta.org/jira/browse/EHC#selectedTab=com.atlassian.jira.plugin.system.project%3Achangelog-panel].