Fórumok

Liferay custom entity caching

Chirag Patel, módosítva 8 év-val korábban

Liferay custom entity caching

New Member Bejegyzések: 6 Csatlakozás dátuma: 2015.04.11. Legújabb bejegyzések
I am using liferay 6.1 version.
I have created custom entities for portlet using service builder. I want to cache that custom entities.

I have set following properties in my portal-ext.properties to enable cache.

ehcache.statistics.enabled=true
value.object.entity.cache.enabled=true
value.object.finder.cache.enabled=true

velocity.engine.resource.manager.cache.enabled=true
layout.template.cache.enabled=true

net.sf.ehcache.configurationResourceName=/custom_cache/hibernate-clustered.xml

log4j.logger.net.sf.ehcache=DEBUG
log4j.logger.net.sf.ehcache.config=DEBUG 
log4j.logger.net.sf.ehcache.distribution=DEBUG
log4j.logger.net.sf.ehcache.code=DEBUG


I created ehcache.xml file to override the ehcache-failsafe.xml to configure my custom entities so that it can enable for caching.

my ehcache.xml file is in my classpath [classpath:liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes].


<diskstore path="java.io.tmpdir/ehcache" />

<diskstore path="java.io.tmpdir/ehcache" />

<defaultcache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />

<cache eternal="false" maxElementsInMemory="10000" name="com.pr.test.model.impl.StudentImpl" overflowToDisk="false" timeToIdleSeconds="600" timeToLiveSeconds="300" statistics="true" copyOnRead="true" copyOnWrite="true" clearOnFlush="true" transactionalMode="off" />



Also create hibernate-clustered.xml file under src path [/docroot/WEB-INF/src] which is same as my ehcache.xml file.
since I am using service builder, cache-enable="true" is enough to cache the entities?

I use Jconsole to monitor the cache hits, But what the problem is the percentage for cache Misses is more than cache hits. Below is my statistics for caching :
Chirag Patel, módosítva 8 év-val korábban

RE: Liferay custom entity caching (Válasz)

New Member Bejegyzések: 6 Csatlakozás dátuma: 2015.04.11. Legújabb bejegyzések
As i figure out that

Caching is enabled by default for services built using liferay service builder.

So no need to configure any thing unless you want to disable caching.

To see the statistics of caching using jconsole follow the link : monitor liferay caching
thumbnail
Neil Francese, módosítva 6 év-val korábban

RE: Liferay custom entity caching

New Member Bejegyzések: 22 Csatlakozás dátuma: 2012.04.03. Legújabb bejegyzések
Did you ever determine why you were getting so many misses?