Caffeine Cache Provider

Last Updated: Jul 2, 2019
documentation for the dotCMS Content Management System

The Caffeine cache provider is a dotCMS implementation of the Caffeine cache by Ben Manes. Caffeine is a local, memory-only cache which provides a higher-performance alternative to the Guava cache provider. 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, and is enabled by default for all cache regions in both Community and Enterprise editions. All customers may change the cache Configuration Properties (see below), and customers with an Enterprise license may change how the Caffeine cache provider is used in each cache region.

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 Cache Region Size

The following parameter configures the default cache size (number of entries) of both the Caffeine and Guava cache:

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

This parameter 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 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 default cache chain includes the Caffeine cache provider by default:

cache.default.chain=com.dotmarketing.business.cache.provider.caffeine.CaffeineCache

Therefore you only need to add the Caffeine cache provider to the cache chain for any new cache chain properties you create for specific cache regions. To add the Caffeine cache provider to the cache chain property for a region, you must add com.dotmarketing.business.cache.provider.caffeine.CaffeineCache to the cache chain properties for the cache regions where you wish to use it. For example, the following property specifies a cache chain for the adminconfigpool cache region that uses only the Caffeine Cache:

cache.adminconfigpool.chain=com.dotmarketing.business.cache.provider.caffeine.CaffeineCache

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

On this page

×

We Dig Feedback

Selected excerpt:

×