Cache Override

問題

This article describes how to override the cache in 7.0 taking into account two different aspects: EhCache settings and Replication settings. The first one implies creating a new module, while the second is accomplished via portal-ext.properties

環境

  • Liferay DXP 7.0

解決

Cache configuration, as with many other elements of Liferay, can be overridden. This override applies to two different aspects:

EhCache settings

In order to increase your cache's performance, some of their attributes, like the time to idle (timeToIdle), capacity (maxElementsInMemory), can be overridden to apply values different than the ones provided by default. To do so you must create a new module. To help doing so you can use the following project.

Inside, in /portal-cache-override-config/src/main/resources/ehcache/ path, you have an override-liferay-multi-vm-clustered.xml file that applies specific configurations for a provided list of caches. The naming of the file must be the following: override-liferay-[multi|single]-vm-clustered.xml depending on whether you want to override SingleVM or MultiVM caches. Once you have decided the name (hence the type) you must edit your proper cache configurations.

Also the PortalCacheConfiguratorSettingsOverrider.java is provided in order to indicate that the override-liferay-[multi|single]-vm-clustered.xmlwill be used to modify the settings. You must only modify this file to indicate the final name of the xml file.

There is more information about these kinds of overrides in the following article: Modifying the cache configuration with a module

Replication settings

How replication is handled, either via copy or via invalidation (default), can be configured using the appropriate portal-ext.properties properties. These different types of replication can be applied to three different types of operations: puts (put operation over a map), updates (put operation over a key that already exists in a map), removals (remove operation over a map).

The naming of the properties is as follows:

Prior to DE-26

ehcache.cluster.link.replicator.properties

ehcache.cluster.link.replicator.properties.TEST_CACHE=replicatePutsViaCopy=true,replicateUpdatesViaCopy=true

 

DE-26 and after

ehcache.replicator.properties

ehcache.replicator.properties.TEST_CACHE=replicatePutsViaCopy=true,replicateUpdatesViaCopy=true

追加情報

Additional information can be found here: Modifying Cache Size Time To Live and Replication in DXP 7.0

 

 

この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています