The H22 cache provider implements a disk cache for dotCMS using the H2 database. For more information on cache providers in dotCMS, please see the Cache Chaining documentation.
The H22 cache provider replaces the original H2 cache provider, to offer an H2 cache which is more flexible and configurable than the original H2 cache provider. The original H2 cache provider is still supported for backward compatibility with older versions, but is deprecated and may eventually be removed. All new cache implementations should use the H22 cache provider instead of the H2 cache provider.
What is H2?
The H2 database is a small, fast, open source database with a small footprint. The H22 cache provider uses the H2 database to implement a disk cache for improved performance and faster load times after a server restart. For more information on the H2 database, please see the official H2 database site.
The H2 database and the H22 cache provider are both included with the dotCMS distribution, but the H22 cache provider may only be enabled by customers with an Enterprise license.
Important Note on Cache Size
Although there are a number of configuration properties to control the behavior of the H22 cache, the H2 database does not provide a mechanism to limit the size of the database, so there is no limit to the size of the H22 cache on disk, and on very large sites the H22 cache may grow to a very large size.
Therefore it is recommended that you use another cache provider in the cache chain (such as the default Caffeine cache provider) before the H22 cache provider, both to improve system performance and to minimize the size of the H2 cache.
In addition, it is recommended that you prune or clear the H22 cache directory (/dotserver/tomcat-X.x.xx/webapps/ROOT/dotsecure/h22 cache) as part of your periodic maintenance procedures, to ensure that the cache files do not grow large enough to cause potential disk space limitations. Since a new cache directory will be automatically created if one does not exist, this can be as simple as periodically removing the directory (e.g.
rm -rf dotsecure/h22cache/*).
The following parameters in the dotmarketing-config.properties control the bahavior of the H22 cache.
Note: It is strongly recommended that you make all changes to the dotmarketing-config.properties file through a properties file extension.
cache.h22.number.of.dbs=2 cache.h22.number.of.tables.per.db=9 cache.h22.limit.one.error.log.per.milliseconds=5000 cache.h22.recover.after.errors=5000 cache.h22.recover.if.restarted.in.milliseconds=30000 cache.h22.db.poolsize.max=500 cache.h22.db.connection.timeout=1000 cache.h22.db.leak.detection.timeout=0 cache.h22.db.extra.params=;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE
|2||Number of H2 databases to use for the cache.|
|9||Number of tables to use for each database.|
|5000||Limit error log messages to one each period (in milliseconds).|
|5000||Recover the database after this many total errors.|
|30000||Re-use the existing cache instead of creating a new cache (avoid a cold cache restart) if the server is restarted within the specified time (in milliseconds).|
|500||The maximum number of H2 connections per database.|
|1000||Database connection timeout (in milliseconds).|
|0 (off)||Report a potential db connection leak if a connection isn’t returned to the pool within the specified timeout (in milliseconds).|
Note: Any value lower than 10000 will be ignored.
|;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE||Additional parameters to pass to the H2 database engine when creating the H2 cache database.|
Cache Chain Properties
In dotCMS Enterprise edition, only the cache chains for the contentletcache and velocitycache regions (
cache.velocitycache.chain) use the H22 cache by default:
Therefore you must add the H22 cache provider to the cache chain for any other cache regions where you wish to use it. To add the H22 cache provider to the cache chain property for a region, you must add
com.dotmarketing.business.cache.provider.h22 to the cache chain property for that cache region. For example, the following property specifies a cache chain for the
adminconfigpool cache region that accesses the Caffeine Cache and then the H22 Cache:
For more information on how to configure cache regions to use the H22 Cache provider, please see the Cache Chaining documentation.