Databases Reference
In-Depth Information
<cacheEventListenerFactory
class="com.liferay.portal.cache.ehcache.
LiferayCacheEventListenerFactory"
properties="replicatePuts=false,replicateUpdatesViaCopy=false"
propertySeparator=","
/>
<bootstrapCacheLoaderFactory class="com.liferay.portal.cache.
ehcache.LiferayBootstrapCacheLoaderFactory" />
</defaultCache>
<cacheeternal="false" maxElementsInMemory="10000"
name="com.liferay.portlet.calendar.service.impl.CalEventLocalUtil"
overflowToDisk="false"timeToIdleSeconds="600">
<cacheEventListenerFactory
class="com.liferay.portal.cache.ehcache.
LiferayCacheEventListenerFactory"
properties="replicatePuts=false,replicateUpdatesViaCopy=false"
propertySeparator=","/>
<bootstrapCacheLoaderFactory class="com.liferay.portal.cache.ehcache.
LiferayBootstrapCacheLoaderFactory" />
</cache>
As shown in the preceding code snippet, we have defined one cache bucket with
a name
com.liferay.portlet.calendar.service.impl.CalEventLocalUtil
.
This cache bucket stores the Calendar-portlet-related service responses in the cache.
We have defined various cache control attributes in the
cache
tag. Some of the
attributes are related to cache replication. Let's understand the important cache
control attributes of the
cache
tag:
•
eternal
: This attribute indicates whether the objects placed in the specific
cache can expire or not. If it is set to
true
, objects in the cache will never
expire. It overrides the value of the
timeToIdleSeconds
attribute. We
configured its value to
false
as we need to make sure cached objects
are removed if they are not used.
•
maxElementsInMemory
: This attribute is important to size in-memory cache.
It defines the maximum number of objects that can be stored in RAM. Once
the number of objects in the cache bucket reaches this number, the cache
manager removes the
least recently used
(
LRU
) object from the cache, if
the
overflowToDisk
attribute is set to
false
.
•
timeToIdleSeconds
: This attribute defines the time for which an object can
be in the cache without utilization. For example, the value of this parameter
is set to 3600 for one of the cache buckets, and there is an object in the cache
bucket which has not been accessed in the last hour. In this situation, such
an object will be removed from the cache bucket. This attribute is also very
important from the point of view of performance.