close

Filter

loading table of contents...

Content Application Developer Manual / Version 2107

Table Of Contents

4.2.3 Configuring Cache Sizes

After defining the data views, make sure to configure the cache correctly, so that the data view objects are not evicted from the cache immediately. An indicator for this situation is the message "Unreasonable Cache Size null for java.lang.Object" in the log file.

To configure the cache, add a <cachesize> element to the data view definition XML file, using attributes to specify the maximum number of cached instances and the object type this configuration should apply to. As a minimal solution, you can insert the line

        <cachesize class="com.coremedia.objectserver.dataviews.AssumesIdentity" size="10000"/>

This will allow a total of 10000 data view objects to be cached.

A more elaborate method would be to partition the cache according to the type of the cached objects. The type of an object is defined either by the Java type hierarchy or, if the object implements the interface com.coremedia.dispatch.HasCustomType, by the result of the method getCustomType(). For ordinary content beans, the Java type hierarchy is used.

You can configure sizes for different types. If multiple types apply for a single cached object, the most specific type is used. For example

<cachesize class="com.company.cms.SuperType" size="1000"/>
<cachesize class="com.company.cms.SubType" size="100"/>

would allow the caching of up to 1000 direct or indirect instances of SuperType as long as these are not also direct or indirect instances of SubType. For SubType, at most 100 instances would be cached. This can make sense if instances of SubType consume a lot of main memory, so that 1000 instances might lead to an OutOfMemoryError.

Because data views extend their bean class, it is sufficient to configure cache sizes for the bean classes. You need not reference the class names of the automatically generated data view classes.

Please note that the configured cache sizes are directly forwarded to the cache of the Unified API in the CAE. That cache is an instance of the class com.coremedia.cache.Cache. That class does not perform any type hierarchy analysis when caching objects. This is only done by the data view factory inside the CAE.

Warning

Warning

Please note that configured values for cache classes for data views may overwrite configured values for cache classes for cache keys, for example if java.lang.Object is configured. Make sure to always use com.coremedia.objectserver.dataviews.AssumesIdentity or classes higher in the class hierarchy if configuring cache classes for DataViews.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.