Skip to content
Norbert Pomaroli edited this page Feb 13, 2017 · 8 revisions

Caching

Caching of objects and in Gentics Content Connector is done by the Gentics Portal Connector datasource.

Additionally rendered contents and plinks are cached in the crcontent cache. TODO: describe this in more detail.

Configuration

in the properties of the servlet

Example:

rp.1.ds.cache=true`
rp.1.ds.cache.foreignlinkattributes=true`
rp.1.ds.cache.syncchecking=true`

Explained:

#With this parameter, the datasource cache can be switched on. Datasource cache will increase performance when accessing objects coming from this datasource.	DEFAULT: false
cache=false

#When enabling the datasource cache for datasources that are filled by Gentics Content.Node;, you should set this to true . When syncchecking is enabled, Gentics Portal.Node checks frequently for an updated contentrepository and will clear all relevant caches.	DEFAULT: false
cache.syncchecking=false

#Interval in seconds for background checks whether the updatetimestamp of a Content Repository has changed (when cache.syncchecking is enabled).	DEFAULT: 10
cache.syncchecking.interval=10	

#When the datasource parameters cache and cache.syncchecking are enabled for this datasource, setting this parameter to true will modify the behaviour of clearing the caches when datasource modifications are detected: By default, all datasource caches (queries, objects, attributes) are cleared, but with differential syncchecking, only the modified objects (and their attributes) are removed from the cache (together with all query results).	DEFAULT: true
cache.syncchecking.differential=true	 

#When caching for this datasource is activated, all attributes would be cached. With this setting, the caching for the attribute attributename can be deactivated.	DEFAULT true
cache.attribute.[attributename]=true

#With this parameter, the cache region for attribute attributename can be defined. This can be used to have better control of how specific attributes will be cached.	 DEFAULT gentics-portal-contentrepository-atts	 
cache.attribute.[attributename].region=gentics-portal-contentrepository-atts	 

#Setting this parameter to true will enable the caching also for foreign link attributes (when the cache is enabled at all). This should not be done for writeable datasources, because the cache for foreign linked attributes can not be dirted correctly and this will most likely lead to inconsistent cache data. If you use caching for a datasource filled from Gentics Content.Node; and have cache.syncchecking set to true, you should also set cache.foreignlinkattributes to true.	DEFAULT:false
cache.foreignlinkattributes=false	

It is possible to deactivate the crcontent cache with setting the crcontentcache property of the RequestPocessor to false, default is true: #deactivate the content cache of the request processor rp.1.crcontentcache=false

in the cache.ccf

A cache.ccf file is needed in the root of the protalnode confpath for the JCS cache to work. In this file it is possible to configure how long the elements should be stored in the cache regions and how many elements can be stored in the cache. It is also possible to configure different kind of caches (RAM and Filesystem Cache), for a detailed description of how to configure JCS please take a look at the JCS Documentation at apache.org

To see which different JCS cache zones are supported by the contenconnector please take a look at the cache.ccf in the sample config.

Clearing the cache

The cache can either be cleared directly using Java and the class CRDatabaseFactory, or you can configure a cache clear servlet, that provides this functionality.

	<servlet>
		<servlet-name>clearcache</servlet-name>
		<servlet-class>com.gentics.cr.servlet.system.ClearCacheServlet</servlet-class>
	</servlet>

You have to configure the datasource for the servlet that should be affected by the cache clear:

#Datasource
ds-handle.type=jdbc
ds-handle.driverClass=com.mysql.jdbc.Driver
ds-handle.url=jdbc:mysql://localhost:3306/lucene_datasource?user=node
ds.cache=true
ds.cache.foreignlinkattributes=true
ds.cache.syncchecking=true
dblazyinit=true

There are two possible modes.

Clear the cache for one item:

/servlet-sample/clearcache?contentid=10007.123

Clear the complete cache for the datasource

/servlet-sample/clearcache?all=true

NavigationCache

In order to enhance the performance of rendering big navigations, it is possible to use the NavigationCacheRequestProcessor, which acts as wrapper around any other RequestProcessor implementation and adds caching of navigation responses.

An example configuration of the NavigationCacheRequestProcessor might look like this:

# Navigation Cache Request Processor wraps the requestprocessor rp.1.rp.1 with a navigation cache
rp.1.rpClass=com.gentics.cr.cache.NavigationCacheRequestProcessor
# Number of threads used for refreshing cached navigations in background
rp.1.threads=2
# Number of seconds, the cached navigations shall be refreshed before the cache would invalidate
rp.1.secondsbeforecache=30

#wrapped RequestProcessor1 gets the elements from Contentrepository
rp.1.rp.1.rpClass=com.gentics.cr.CRRequestProcessor
#Datasource
rp.1.rp.1.ds-handle.type=jdbc
rp.1.rp.1.ds-handle.driverClass=com.mysql.jdbc.Driver
rp.1.rp.1.ds-handle.url=jdbc:mysql://localhost:3306/lucene_datasource?user=node
rp.1.rp.1.ds.cache=true
rp.1.rp.1.ds.cache.foreignlinkattributes=true
rp.1.rp.1.ds.cache.syncchecking=true

Internally, the NavigationRequestProcessor uses JCS Cache with the cache region gentics-cr-navigation.

Example cache configuration in the cache.ccf file. This file has to be located in the root of the configured gentics config path:

## cache region for the Navigation Cache
jcs.region.gentics-cr-navigation=
## max elements in cache
jcs.region.gentics-cr-navigation.cacheattributes.MaxObjects=1000
## cache time for navigation objects
jcs.region.gentics-cr-navigation.elementattributes.MaxLifeSeconds=3600

The NavigationCache now polls the requested Navigation Object in the background by generating a ScheduledThreadPoolExecutor instance that frequently updates the cache objects before the they are marked as invalid. After one initial request for a navigation object there will be no more blocking cache fetching operations.

Using Gentics Content Connector in Gentics Portal.Node

If you are using the Gentics Content Connector in Gentics Portal.Node you probably also want to use the Caches provided by the portal. Otherwise the JCS Admin will not show the statistics properly.

To tell the Gentics Conntent Connector to use the caches provided by the portal, simply put the following line at the top of your cache.ccf file. com.gentics.cr.useportalcaches=true

Using Gentics Content Connector in Gentics Portal.Node PHP

It is important to disable the content caches for the contentconnector since this prevents binary files from being refreshed for a long time. Be sure to include rp.1.crcontentcache=false in your configuration!