Using cache Java libraries in custom osgi modules

How using cache to persist some values in service builder modules to cache data retrieved from rest api? Do I need the liferay-multi-vm.xml?

Which is the approach/guide lines in Liferay 7.4?

1 Answer

1

Hi @Moozo,

Service Builder enables service entities and service entities finder results cache by default. Please see: Service Builder - Liferay Official Documentation - Liferay Learn

However, if you want to modify the cache for Service Builder Service Entities or Entity Finder results, then you need to override liferay-*-vm.xml. For more info on this, you can refer to our legacy documentation: Legacy Documentation - Liferay Official Documentation - Liferay Learn → Developing Liferay DXP 7.2 → chapter 329 (Overriding Cache)

I mean using cache Java libraries to cache data retrieved from external web services (my Logic Is inside the LocalServiceImpl class)

You can use the Liferay cache functionality. import com.liferay.portal.kernel.cache.PortalCache; import com.liferay.portal.kernel.cache.PortalCacheHelperUtil; PortalCache cache = PortalCacheHelperUtil.getPortalCache(PortalCacheManagerNames.SINGLE_VM, name); cache.put( key, value, ttl); cache.get( key); cache.removeAll(); Or MULTI_VM cache in a cluster.