Caffeine Cache Provider - Documentation topics on: cache properties,cache providers,cache settings,configuring the dotcms cache,memory-only cache,.

This documentation is a static copy for this version. For current documentation, see: http://dotcms.com/docs/latest

Caffeine Cache Provider

The Caffeine cache provider is a dotCMS implementation of the Caffeine cache by Ben Manes. Caffeine can be used as a higher-performance alternative to the Guava cache provider configured by default in dotCMS. For more information on cache providers in dotCMS, please see the Cache Properties documentation.

What is Caffeine?

Caffeine is a local, high-performance, memory-only cache library. Caffeine was designed specifically as an improvement over the Guava cache, including but not limited to the following:

  • Automatic loading of entries into the cache, optionally asynchronously.
  • Size-based eviction when a maximum is exceeded based on frequency and recency.
  • Time-based expiration of entries, measured since last access or last write.
  • Asynchronous refresh when the first stale request for an entry occurs.
  • Writes propagated to an external resource

For more information about Caffeine, please see the Caffeine page on Github or the Caffeine user's guide.

Caffeine in dotCMS

A Caffeine cache provider is included with dotCMS, but is not enabled by default. Customers with an Enterprise license may change the default cache region or individual cache regions to use the Caffeine cache (instead of, or possibly in addition to, the default Guava cache provider).

Configuration Properties

Since Caffeine was intentionally developed to be compatible with the Guava cache, it shares many of the same features as the Guava cache, and the dotCMS Caffeine cache provider shares the same configuration properties as the dotCMS Guava cache with the exception of the cache.concurrencylevel property (since Caffeine cache does not use a segmented cache). The following parameters in the dotmarketing-config.properties control the bahavior of both the Caffeine cache and the Guava cache.

  • Note: It is strongly recommended that all changes to the dotmarketing-config.properties file be made through a properties extension file.

Default Properties

The following parameters configure the default cache sizes (number of entries) of both the Caffeine and Guava cache:

## Guava Cache Size Settings
cache.default.size=1000
cache.livecache.size=1000
cache.workingcache.size=1000

Where:

  • cache.default.size specifies the default cache size (number of entries), which will be used for any cache region which does not have a cache size set explicitly (see below).
  • cache.livecache.size specifies the default size (number of entries) for the cache storing live versions of pages.
  • cache.workingcache.size specifies the default size (number of entries) for the cache storing working versions of pages.

Cache Region Sizes

In addition to the default cache settings, you can also specify the size (number of entries) of each cache region (again, for both the Caffeine and Guava caches), giving you the flexibility to tune the cache for the specific design of your site. The following settings are the defaults, but may be modified by editing these properties:

## Region Specific Guava cache Settings
cache.adminconfigpool.size=100
cache.blockdirectivecache.size=1000
cache.categorybykeycache.size=1000
cache.categorycache.size=1000
cache.categorychildrencache.size=1000
cache.categoryparentscache.size=1000
cache.companypool.size=10
cache.contentletcache.size=5000
cache.fileassetmetadatacache.size=200
cache.dotcmslayoutcache.size=1000
cache.dotcmsrolecache.size=1000
cache.dotcmsrolekeycache.size=1000
cache.dotcmsuserrolecache.size=1000
cache.fieldscache.size=1000
cache.filecache.size=1000
cache.foldercache.size=1000
cache.hostaliascache.size=1000
cache.hostcache.size=1000
cache.hostvariablescache.size=1000
cache.htmlpagecache.size=1000
cache.identifiercache.size=50000
cache.languagecacheimpl.size=1000
cache.navcache.size=1000
cache.parentpermissionablecache.size=10000
cache.permissioncache.size=50000
cache.plugincache.size=1000
cache.portletpool.size=100
cache.structurecache.size=500
cache.templatecache.size=500
cache.userdotcmscache.size=1000
cache.useremaildotcmscache.size=1000
cache.userproxycache.size=1000
cache.velocitycache.size=1000
cache.velocitymenucache.size=1000
cache.velocitymisscache.size=1000
cache.versioncache.size=50000
cache.versioninfocache.size=50000
cache.virtuallinkscache.size=1000
cache.workflowcache.size=1000
cache.workflowstepcache.size=1000
cache.workflowtaskcache.size=10000
cache.indiciescache.size=8
cache.publishingendpointcache.size=100
cache.workflowactioncache.size=10000
cache.logmappercache.size=10
cache.translatedquerycache.size=5000
cache.csscache.size=2500
cache.dotcmsrootrolescache.size=1000
cache.identifier404cache.size=1000
cache.fieldsvarcache.size=1000
cache.relationshipcachebyname.size=1000
cache.relationshipcachebyinode.size=1000
cache.propertycache.size=1000
cache.containercache.size=1000
cache.newnotificationcache.size=1000
cache.containerstructurecache.size=1000
cache.blockdirectivehtmlpagecache=1000
cache.pushedassetscache=5000
cache.ratingcache=1000
cache.velocityuservtlcache=500

Cache Chain Properties

The Caffeine cache is not configured for any cache regions by default.

To use the Caffeine cache in place of the Guava cache for all cache regions, you must replace com.dotmarketing.business.cache.provider.guava.GuavaCache with com.dotmarketing.business.cache.provider.caffeine.CaffeineCache in both the default cache region and all cache regions where the Guava cache is currently specified. For example, the following configuration settings replace the Guava cache with the Caffeine cache in the default cache chain configuration shipped with dotCMS:

cache.default.chain=com.dotmarketing.business.cache.provider.caffeine.CaffeineCache
cache.velocitymemoryonlycache.chain=com.dotmarketing.business.cache.provider.caffeine.CaffeineCache
cache.contentletcache.chain=com.dotmarketing.business.cache.provider.caffeine.CaffeineCache,com.dotmarketing.business.cache.provider.h22.H22Cache
cache.velocitycache.chain=com.dotmarketing.business.cache.provider.caffeine.CaffeineCache,com.dotmarketing.business.cache.provider.h22.H22Cache

For more information on how to configure cache regions to use the Caffeine Cache provider, please see the Cache Chaining documentation.