Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
Magnolia uses Ehcache for its back-end cache functionality. Ehcache is a robust, proven and full-featured cache product which has made it the most widely-used Java cache.
We recommend you use Ehcache 3 module instead.
Compared with Ehcache 2, the 3.x line brings important changes and improvements such as full compatibility with javax.cache API (JSR-107), off-heap storage capabilities, a revamped API, persistence, improved performance over Ehcache 2.x and much more.
<dependency> <groupId>info.magnolia.cache</groupId> <artifactId>magnolia-cache-ehcache</artifactId> <version>5.6.5</version> </dependency>
Ehcache has its own configuration options that can be set in
You can use a different cache library as long as you implement Java interfaces that allow you to configure caching behavior in the Configuration app. The library can be changed by implementing Cache and CacheFactory . A cache factory is an interface that wraps the functionality and hides the configuration mechanism of the library you choose.
Instructs Ehcache to wait the specified time in milliseconds before attempting to cache the request. Create the
|Number of seconds between runs of the disk expiry thread.|
|Size to allocate to DiskStore for a spool buffer. Writes are made to this area and then asynchronously written to disk. Default: 30MB. Each spool buffer is used only by its cache. If OutOfMemory errors, you may need to lower this value. To improve DiskStore performance consider increasing it. Trace level logging in the DiskStore will show if put back ups are occurring.|
|If elements are set to eternal, timeouts are ignored and the element is never expired.|
|Sets maximum number of objects that will be created in memory. |
|Sets maximum number of objects maintained in the DiskStore. The default value of zero means unlimited.|
Policy is enforced upon reaching the maxElementsInMemory limit. Available policies:
|Permits elements to overflow to disk when the memory store has reached the maxInMemory limit.|
|Optional attribute. Sets max idle time between accesses for an element before it expires. Only used if the element is not eternal. A value of |
|Sets lifespan for an element. Only used if the element is not eternal. Optional attribute. A value of |
When using the same webapp with ehcache for both author and public instance
If you are using the same webapp with ehcache for both author and public instance, you must set the property
magnolia.cache.manager.id in the magnolia.properties file. Make sure to assign different values for the different contexts!
If you do not set the property - the second starting instance will throw an exception:
net.sf.ehcache.CacheException: javax.management.InstanceAlreadyExistsException: net.sf.ehcache:type=CacheManager,name=/path-to-webapp#info.magnolia.module.cache.ehcache.EhCacheFactory#cacheManager