List of usage examples for com.liferay.portal.kernel.cache PortalCache get
@Proxy
public V get(K key);
From source file:br.com.thiagomoreira.liferay.plugins.MarkdownDisplayPortlet.java
License:Apache License
@Override public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { PortletPreferences preferences = request.getPreferences(); String markdownURL = preferences.getValue("markdownURL", null); int timeToLive = 60 * GetterUtil.getInteger(preferences.getValue("timeToLive", "1")); boolean autolinks = GetterUtil.getBoolean(preferences.getValue("autolinks", "false")); boolean fencedBlockCodes = GetterUtil.getBoolean(preferences.getValue("fencedBlockCodes", "false")); boolean tables = GetterUtil.getBoolean(preferences.getValue("tables", "false")); if (Validator.isNotNull(markdownURL)) { PortalCache<Serializable, Object> portalCache = SingleVMPoolUtil .getCache(MarkdownDisplayPortlet.class.getName()); String content = (String) portalCache.get(markdownURL); if (content == null) { int options = Extensions.NONE; if (autolinks) { options = options | Extensions.AUTOLINKS; }// w w w . j av a2s . c om if (fencedBlockCodes) { options = options | Extensions.FENCED_CODE_BLOCKS; } if (tables) { options = options | Extensions.TABLES; } PegDownProcessor processor = new PegDownProcessor(options); String markdownSource = HttpUtil.URLtoString(markdownURL); content = processor.markdownToHtml(markdownSource); portalCache.put(markdownURL, content, timeToLive); } request.setAttribute("content", content); } else { request.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.TRUE); } super.render(request, response); }
From source file:com.liferay.memleak.MemLeakPortlet.java
License:Open Source License
public void cacheMiss(ActionRequest request, ActionResponse response) { final PortalCache<Serializable, Object> cache = SingleVMPoolUtil .getCache("com.liferay.portal.servlet.filters.sso.ntlm.NtlmFilter"); for (int i = 0; i < 1000; i++) { cache.get(UUID.randomUUID().toString()); }/*from w w w . ja v a 2 s .c o m*/ }
From source file:com.liferay.memleak.MemLeakPortlet.java
License:Open Source License
public void cacheHit(ActionRequest request, ActionResponse response) { final PortalCache<Serializable, Object> cache = SingleVMPoolUtil .getCache("com.liferay.portal.servlet.filters.sso.ntlm.NtlmFilter"); cache.put("test", "test"); for (int i = 0; i < 1000; i++) { cache.get("test"); }//from w ww . ja va 2 s . co m }