Test Cache Provider

Last Updated: May 12, 2021
documentation for the dotCMS Content Management System

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

Operation

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:

cache.adminconfigpool.chain=com.dotmarketing.business.cache.provider.timedcache.TimedCacheProvider,com.dotmarketing.business.cache.provider.guava.TestCacheProvider,com.dotmarketing.business.cache.provider.h2.H2CacheLoader

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"/>
        </Async>

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

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"/>
        </Logger>

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.

Thus:

  • 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.

On this page

×

We Dig Feedback

Selected excerpt:

×