Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Replace the MultiVMPoolUtil calls in Liferay 7.2
Hi All,
We have many calls related to MultiVMPoolUtil in Liferay 6.1 and we are trying to upgrade it to Liferay 7.2.Let me know how i can upgrade the following calls -
(Map<Long, Library>) MultiVMPoolUtil.get(LIBRARY_BY_ID_CACHE_NAME, cacheKey);
MultiVMPoolUtil.put(LIBRARY_BY_ID_CACHE_NAME, cacheKey, resourceLibraryById);
We have many calls related to MultiVMPoolUtil in Liferay 6.1 and we are trying to upgrade it to Liferay 7.2.Let me know how i can upgrade the following calls -
(Map<Long, Library>) MultiVMPoolUtil.get(LIBRARY_BY_ID_CACHE_NAME, cacheKey);
MultiVMPoolUtil.put(LIBRARY_BY_ID_CACHE_NAME, cacheKey, resourceLibraryById);
MultiVMPoolUtil just dispatched all method calls to MultiVMPool, so you should use that one directly. e.g.
@Component
public class YourClass {
@Reference
private MultiVMPool multiVMPool;
...
}
@Component
public class YourClass {
@Reference
private MultiVMPool multiVMPool;
...
}
Thanks for your response , appreciate that
Is this the way to execute the change to use MultiVMPool : For a 6.1 code statement (Map<Long, Library>) MultiVMPoolUtil.get(LIBRARY_BY_ID_CACHE_NAME, cacheKey)
Is this correct change for similar code change for 7.2 ?PortalCacheManager<?, ?> portalCacheManager = PortalCacheManagerProvider.getPortalCacheManager(LIBRARY_BY_ID_CACHE_NAME);
return (Map<Long, Library>) portalCacheManager.fetchPortalCache(cacheKey)
Is this correct change for similar code change for 7.2 ?PortalCacheManager<?, ?> portalCacheManager = PortalCacheManagerProvider.getPortalCacheManager(LIBRARY_BY_ID_CACHE_NAME);
return (Map<Long, Library>) portalCacheManager.fetchPortalCache(cacheKey)
There is no fetch method. I would do this to get the cache and then a value from it:
PortalCache<String, Map<Long, Library> > portalCache = PortalCache<String, Map<Long, Library>>) multiVMPool.getPortalCache( "UNIQUE CACHE KEY); //Usually the class name of the current class is used as cache key
return portalCache.get(cacheKey);
PortalCache<String, Map<Long, Library> > portalCache = PortalCache<String, Map<Long, Library>>) multiVMPool.getPortalCache( "UNIQUE CACHE KEY); //Usually the class name of the current class is used as cache key
return portalCache.get(cacheKey);
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™