You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2008/10/22 00:15:27 UTC
svn commit: r706797 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH:
ChangeLog src/webdocs/rss.jsp
Author: jalkanen
Date: Tue Oct 21 15:15:26 2008
New Revision: 706797
URL: http://svn.apache.org/viewvc?rev=706797&view=rev
Log:
[JSPWIKI-138] rss.jsp now caches the produced XML in a custom
cache, resulting in *very* fast operation.
Modified:
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/rss.jsp
Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=706797&r1=706796&r2=706797&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Tue Oct 21 15:15:26 2008
@@ -5,6 +5,9 @@
* [JSPWIKI-348] OC4J compatibility, thanks to Lutz Tietze.
* [JSPWIKI-389] Wrong mixed quotes in SecurityConfig.jsp corrected.
+
+ * [JSPWIKI-138] rss.jsp now caches the produced XML in a custom
+ cache, resulting in *very* fast operation.
2008-10-17 Janne Jalkanen <ja...@apache.org>
Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/rss.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/rss.jsp?rev=706797&r1=706796&r2=706797&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/rss.jsp (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/rss.jsp Tue Oct 21 15:15:26 2008
@@ -5,10 +5,13 @@
<%@ page import="java.text.*" %>
<%@ page import="com.ecyrd.jspwiki.rss.*" %>
<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ page import="com.opensymphony.oscache.base.*" %>
<%@ taglib uri="/WEB-INF/oscache.tld" prefix="oscache" %>
<%!
Logger log = Logger.getLogger("JSPWiki");
+ Cache m_cache = new Cache( true, false, false, true,
+ "com.opensymphony.oscache.base.algorithm.LRUCache", 256 );
%>
<%
@@ -104,10 +107,37 @@
response.addDateHeader("Last-Modified",latest.getTime());
response.addHeader("ETag", HttpUtil.createETag(wikipage) );
-%>
-<%-- <oscache:cache time="300"> --%>
-<%
- out.println(wiki.getRSSGenerator().generateFeed( wikiContext, changed, mode, type ));
-%>
-<%-- </oscache:cache> --%>
-<% w.exitState(); %>
+
+ //
+ // Try to get the RSS XML from the cache. We build the hashkey
+ // based on the LastModified-date, so whenever it changes, so does
+ // the hashkey so we don't have to make any special modifications.
+ //
+ // TODO: Figure out if it would be a good idea to use a disk-based
+ // cache here.
+ //
+ String hashKey = wikipage.getName()+";"+mode+";"+type+";"+latest.getTime();
+
+ String rss = "";
+
+ try
+ {
+ rss = (String)m_cache.getFromCache(hashKey);
+ }
+ catch( NeedsRefreshException e )
+ {
+ try
+ {
+ rss = wiki.getRSSGenerator().generateFeed( wikiContext, changed, mode, type );
+ m_cache.putInCache(hashKey,rss);
+ }
+ catch( Exception e1 )
+ {
+ m_cache.cancelUpdate(hashKey);
+ }
+ }
+
+ out.println(rss);
+
+ w.exitState();
+ %>