The Hazelcast cache provider can be implemented as either a local or distributed memory-only cache for dotCMS. For more information on cache providers in dotCMS, please see the Cache Properties documentation.
What is Hazelcast?
Hazelcast is a leading, open-source, in-memory data grid framework that provides protocols and services to enable simmplified distributed computing services including caching, processing, queries, clustering, and storage. dotCMS currently utilizes Hazelcast for both distributed cluster and cache management.
For more information about Hazelcast, please visit the official Hazelcast website.
Hazelcast in dotCMS
dotCMS currently implements portions of the Hazelcast caching and clustering architecture via an optional cache provider and via dotCMS cluster services.
The Hazelcast cache provider included with dotCMS can be used to enable either a Hazelcast distributed or local (“near”) cache. This cache provider is not enabled by default; customers with an Enterprise license may change the default cache region or individual cache regions to use the Hazelcast cache (instead of, or possibly in addition to, the default Caffeine cache provider).
Important:
- The Hazelcast cache provider is primarily intended for use as a distributed cache for use with clusters.
- It is recommended that you do not use the Hazelcast cache provider with a stand-alone dotCMS server implementation.
- The Hazelcast cache provider provides no benefit over other in-memory cache implementations when implemented on a single server.
- For single server implementations, you should use the default Caffeine cache provider or the Guava cache provider instead.
- The Hazelcast cache provider is independent of the Hazelcast features implemented for dotCMS clusters.
- Neither the configuration nor the operation of the Hazelcast cache provider has any effect on Hazelcast features implemented with dotCMS clusters, and you may use a cache provider other than the Hazelcast cache provider with dotCMS clusters without any impact on cluster performance.
Cache Chain Properties
The Hazelcast cache is not configured to be used with any cache regions by default. You must explicitly configure the Hazelcast cache provider for all cache regions where you want to use it.
Embedded (Near) Cache
To configure the Hazelcast cache provider in embedded (or “near”) mode, you must add the following cache provider to the appropriate cache chain:
com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded
Distributed (Client) Cache
To configure the Hazelcast cache provider in distributed (or “client”) mode, you must add the following cache provider to the appropriate cache chain:
com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderClient
Example
For example, to use the embedded (“near”) Hazelcast cache in place of the Caffeine cache for all cache regions specified in the default dotCMS configuration, you must replace com.dotmarketing.business.cache.provider.caffeine.CaffeineCache
with com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded
in both the default cache region and all cache regions where the Caffeine cache is currently specified. For example, the following configuration settings replace the Caffeine cache with the Hazelcast cache in the default cache chain configuration shipped with dotCMS:
cache.default.chain=com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded
cache.velocitymemoryonlycache.chain=com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded
cache.contentletcache.chain=com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded,com.dotmarketing.business.cache.provider.h22.H22Cache
cache.velocitycache.chain=com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded,com.dotmarketing.business.cache.provider.h22.H22Cache
For more information on how to configure cache regions to use the Hazelcast Cache provider, please see the Cache Chaining documentation.
Configuration Properties
Since Hazelcast is used for much more than just caching, please see the following important Hazelcast configuration documentation:
Cache Region Size
You may change the size of the Hazelcast cache region by editing the Hazelcast configuration files in your dotCMS distribution.
Note: It is strongly recommended that you make all changes to the Hazelcast configuration files through a configuration plugin.
Embedded (Near) Cache Size Configuration
If Hazelcast cache is being run as Embedded or “near cache” then the cache size can be set in the hazelcast-embedded.xml
file:
<ROOT_DIRECTORY>/dotserver/tomcat/webapps/ROOT/WEB-INF/classes/hazelcast-embedded.xml
The max-size
property can be set in Bytes:
<map name="identifiercache">
<max-size>50000</max-size>
<eviction-policy>LFU</eviction-policy>
</map>
Client (Far) Cache Size Configuration
If Hazelcast cache is being run as Client or “far cache” then the cache size can be set in the hazelcast-client.xml
file:
<ROOT_DIRECTORY>/dotserver/tomcat/webapps/ROOT/WEB-INF/classes/hazelcast-client.xml
The max-size
property can be set in Bytes:
<near-cache name="identifiercache">
<max-size>50000</max-size>
<eviction-policy>LFU</eviction-policy>
<in-memory-format>OBJECT</in-memory-format>
</near-cache>