RE: Replace the MultiVMPoolUtil calls in Liferay 7.2

thumbnail
Rajesh Chaurasia, modified 5 Years ago. Regular Member Posts: 183 Join Date: 8/18/11 Recent Posts
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);
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
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;
...
}
thumbnail
Rajesh Chaurasia, modified 5 Years ago. Regular Member Posts: 183 Join Date: 8/18/11 Recent Posts
Thanks for your response , appreciate that
thumbnail
Rajesh Chaurasia, modified 5 Years ago. Regular Member Posts: 183 Join Date: 8/18/11 Recent Posts
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)
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
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);