Databases Reference
In-Depth Information
•
overflowToDisk
: This flag indicates whether to move cached objects to
the filesystem when the number of objects in-memory exceeds the limit.
Internally, the cache manager uses serialization and deserialization to
read and write objects on the filesystem.
It is not mandatory to define a cache bucket in the configuration file. The Ehcache
framework also allows for creating new cache buckets programmatically. In that
situation, a cache bucket is created with the default cache control attributes. The
default cache control attributes are provided by the
defaultCache
element in
the configuration file. In the previous snippet, we have set the same cache control
attributes in the
defaultCache
element.
We learned about the importance and use of cache control attributes. Let's talk
about the best practices associated with them:
• It is recommended to disable the
overflowToDisk
attribute. If it is enabled,
it will generate more IO and will ultimately affect the performance. If
the system is expected to have a huge amount of cache, it is a good idea
to choose a centralized cache such as Terracotta rather than enabling the
overflowToDisk
attribute.
• It is recommended to set the
eternal
attribute to
false
. It is fine to enable
this attribute when the number of elements in the cache bucket is low and
they are accessed frequently by the Portal.
• It is recommended to configure the
maxElementsInMemory
attribute as
per the application need. It has to be calculated properly based on the
application need. If the value is low, cache objects are removed frequently
from the cache.
• Depending upon the application need,
timeToIdleSeconds
should be
properly configured for every cache bucket. If the value is too low, cache
objects are frequently removed from the cache. Similarly, if the value is
high, the system will occupy memory for unused cached objects.
As there are so many cache buckets to tune cache control parameters, we need to first
decide which cache buckets are of our interest. This can be decided based on the kind
of features that we are using. For example, Portal heavily uses collaboration features.
In that situation, some of the important cache buckets could be as follows:
com.liferay.portal.kernel.dao.orm.EntityCache.com.liferay.portlet.
blogs.model.impl.BlogsEntryImpl
com.liferay.portal.kernel.dao.orm.EntityCache.com.liferay.portlet.
wiki.model.impl.WikiPageImpl
com.liferay.portal.kernel.dao.orm.EntityCache.com.liferay.portlet.
messageboards.model.impl.MBCategoryImpl
com.liferay.portal.kernel.dao.orm.EntityCache.com.liferay.portlet.
messageboards.model.impl.MBThreadImpl