Test Cache Provider - Documentation topics on: cache chaining,cache providers,testing,troubleshooting,.

Test Cache Provider

The Test Cache Provider is a special cache provider used to test and troubleshoot cache chains and cache performance.


The Test Cache Provider:

  • Logs a message to the log file every time it is accessed.
  • Does not actually cache any data.
  • Automatically passes all data to the next cache provider in the chain.

Configuration Properties

There are no configuration properties to change the behavior of the Test cache provider; it automatically logs a message every time it is accessed.

Cache Chain Properties

To use the Test cache provider, you must insert it into the cache chain before the cache region you wish to monitor. To add the Test cache provider to the cache chain property for a region, you must add com.dotmarketing.business.cache.provider.Guava.TestCacheProvider 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 accesses the Timed Cache and then the H2 Cache, but logs all accesses to the H2 Cache by inserting the Test cache provider into the chain before the H2 Cache:


Logging Configuration

By default, all log messages from the Test cache provider will be logged to the main dotCMS log file (dotcms.log). You may configure dotCMS to log messages from the Test cache provider to a different file by changing the dotCMS Logging Configuration.

For example, to log all messages from the Test cache provider to a new file named “TestCache.log”, make the following changes to the Log4j2.xml file:

1. <Properties> Section

Add the following lines to the <Properties> section of the log4j2.xml file:

    <Property name="TEST_CACHE_LOG_FILE">${sys:DOTCMS_LOGGING_HOME}/TestCache.log</Property>
    <Property name="TEST_CACHE_FILENAME_PATTERN">${sys:DOTCMS_LOGGING_HOME}/$${date:yyyy-MM}/TestCache-%d{MM-dd-yyyy}-%i.log.gz</Property>

2. <Appenders> Section

Add the following lines to the <Appenders> section of the log4j2.xml file:

        <Async name="testcache">
            <AppenderRef ref="TESTCACHE-FILE"/>

        <RollingFile name="TESTCACHE-FILE"
            <PatternLayout pattern="${MESSAGE_PATTERN}"/>
                <SizeBasedTriggeringPolicy size="20MB"/>
            <DefaultRolloverStrategy max="10"/>

3. <Loggers> Section

Add the following lines to the <Loggers> section of the log4j2.xml file:

        <Logger name="com.dotmarketing.business.cache.provider.guava.TestCacheProvider" level="info" additivity="false">
            <AppenderRef ref="testcache"/>

Performance Warnings

It is important to note that the Test cache provider reduces cache performance. Although all data is immediately passed to the next cache provider in the chain:

  • The Test cache provider may greatly increase logging, which can significantly impact performance.
  • The Test cache provider adds small additional overhead to receive and pass the data up and down the chain.


  • Cache and system performance should not be evaluated with the Test cache provider in the cache chain.
  • The Test cache provider should not be used in a production environment.

For more information on using the Test cache provider, please see the Troubleshooting section of the Cache Chaining documentation.