How to reduce database load by caching
From Resin 3.0
cache.jsp
<%@ page import="com.caucho.cluster.*" %> <%! @javax.webbeans.Current Cache _cache; %> <% String value = (String) _cache.get("my-key");
if (value != null) { out.println("old: " + value); } else { value = calculate_slow_value(); _cache.put("my-key", value); out.println("new: " + value); } %>
WEB-INF/resin-web.xml
<web-app xmlns="http://caucho.com/ns/resin" xmlns:cluster="urn:java:com.caucho.cluster"> <cluster:TriadCache name="my-cache"/> </web-app>