Commits

Anonymous committed 7038d71

more hints added

Comments (0)

Files changed (6)

docs/wiki/API Usage.html

 	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
 		    <tr>
 			    <td valign="top" class="pagebody">
-				    <p>Beside the <a href="JSP Tags.html" title="JSP Tags">JSP tag library</a> and the <a href="CacheFilter.html" title="CacheFilter">CacheFilter</a> you can use OSCache through its straightforward API. E.g.   you can use the <a href="http://www.opensymphony.com/oscache/api/com/opensymphony/oscache/general/GeneralCacheAdministrator.html" title="Visit page outside Confluence">GeneralCacheAdministrator</a> to create, flush and administrate the cache.</p>
+				    <p>Beside the <a href="JSP Tags.html" title="JSP Tags">JSP tag library</a> and the <a href="CacheFilter.html" title="CacheFilter">CacheFilter</a> you can use OSCache through its straightforward API. You can use the <a href="http://www.opensymphony.com/oscache/api/com/opensymphony/oscache/general/GeneralCacheAdministrator.html" title="Visit page outside Confluence">GeneralCacheAdministrator</a> to create, flush and administrate the cache. The GeneralCacheAdministrator has a cache instance and delegates different Cache's methods. Furthermore the GeneralCacheAdministrator is in charge of load the <a href="Configuration.html" title="Configuration">cache.properties</a> and create a cache instance with the properties definded.</p>
 
 <h4><a name="APIUsage-Typicalusewithfailover"></a>Typical use with fail over</h4>
 

docs/wiki/CacheFilter Tutorial.html

 <span class="code-tag">&lt;/filter-mapping&gt;</span></pre>
 </div></div>
 
-<h4><a name="CacheFilterTutorial-Example3"></a>Example 3</h4>
+<h3><a name="CacheFilterTutorial-Usingthefilter"></a>Using the filter</h3>
 
-<p>A simple example how to use the <a href="CacheFilter.html#CacheFilter-ICacheKeyProvider" title="ICacheKeyProvider on CacheFilter">ICacheKeyProvider</a> parameter of the CacheFilter. The cache key in constructed with the two request parameters <em>pageid</em> and <em>pagination</em>.</p>
+<h4><a name="CacheFilterTutorial-Example1%3AICacheKeyProvider"></a>Example 1: ICacheKeyProvider</h4>
+
+<p>A simple example how to use the <a href="CacheFilter.html#CacheFilter-ICacheKeyProvider" title="ICacheKeyProvider on CacheFilter">ICacheKeyProvider</a> parameter of the CacheFilter. The cache key in constructed with the http request URI and with two request parameters <em>pageid</em> and <em>pagination</em>.</p>
 
 <div class="code"><div class="codeContent">
 <pre class="code-java"><span class="code-keyword">import</span> javax.servlet.http.HttpServletRequest;
 <span class="code-keyword">import</span> com.opensymphony.oscache.web.ServletCacheAdministrator;
 <span class="code-keyword">import</span> com.opensymphony.oscache.web.filter.ICacheKeyProvider;
 
-<span class="code-keyword">public</span> class InsideCacheKeyProvider <span class="code-keyword">implements</span> ICacheKeyProvider {
+<span class="code-keyword">public</span> class ExampleCacheKeyProvider <span class="code-keyword">implements</span> ICacheKeyProvider {
 
     <span class="code-keyword">public</span> <span class="code-object">String</span> createCacheKey(HttpServletRequest httpRequest, ServletCacheAdministrator scAdmin, Cache cache) {
 
         <span class="code-comment">// buffer <span class="code-keyword">for</span> the cache key
 </span>        <span class="code-object">StringBuffer</span> buffer = <span class="code-keyword">new</span> <span class="code-object">StringBuffer</span>(100);
         
-        <span class="code-comment">// part 1 of the key: the page id
+        <span class="code-comment">// part 1 of the key: the request uri
+</span>        buffer.append(httpRequest.getRequestURI());
+        
+        <span class="code-comment">// separation
+</span>        buffer.append('_');
+
+        <span class="code-comment">// part 2 of the key: the page id
 </span>        buffer.append(httpRequest.getParameter(<span class="code-quote">"pageid"</span>));
         
         <span class="code-comment">// separation
 </span>        buffer.append('_');
         
-        <span class="code-comment">// part 2 of the key: the pagination
+        <span class="code-comment">// part 3 of the key: the pagination
 </span>        buffer.append(httpRequest.getParameter(<span class="code-quote">"pagination"</span>));
         
         <span class="code-keyword">return</span> buffer.toString();
 }</pre>
 </div></div>
 
+<p>You can use session attributes values for the cache key also, if request parameters aren't available or e.g. security settings have to be add to the cache key.</p>
+
+<h4><a name="CacheFilterTutorial-Example2%3AFlush"></a>Example 2: Flush</h4>
+
+<p>The flush example shows how to flush a CacheFilter with scope <em>application</em> based on group names. In this example the http servlet request of the user is required to get the cache object.</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> com.opensymphony.oscache.base.Cache;
+<span class="code-keyword">import</span> com.opensymphony.oscache.web.ServletCacheAdministrator;
+
+<span class="code-keyword">import</span> java.util.Collection;
+<span class="code-keyword">import</span> java.util.Iterator;
+
+<span class="code-keyword">import</span> javax.servlet.http.HttpServletRequest;
+<span class="code-keyword">import</span> javax.servlet.jsp.PageContext;
+
+<span class="code-keyword">public</span> class OSCacheAdmin {
+    
+    /**
+     * flush the CacheFilter according to dependent group
+     *
+     * @param request the HttpServletRequest of the user
+     * @param groupNames a string collection of group names
+     */
+    <span class="code-keyword">public</span> <span class="code-keyword">static</span> void flushCacheGroup(HttpServletRequest request, Collection groupNames) {
+    	Cache cache = ServletCacheAdministrator.getInstance(request.getSession().getServletContext()).getCache(request, PageContext.APPLICATION_SCOPE); 
+        Iterator groups = groupNames.iterator();
+        <span class="code-keyword">while</span> (groups.hasNext()) {
+            <span class="code-object">String</span> group = (<span class="code-object">String</span>) groups.next();
+            cache.flushGroup(group);
+        }
+    }
+}</pre>
+</div></div>
+
+<p>If you're CacheFilter is running with scope <em>session</em>, you have to get the cache as follows:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java">Cache cache = ServletCacheAdministrator.getInstance(request.getSession(<span class="code-keyword">true</span>).getServletContext()).getCache(request, PageContext.SESSION_SCOPE);</pre>
+</div></div>
+
                     			    </td>
 		    </tr>
 	    </table>

docs/wiki/CacheFilter.html

     <span class="code-tag">&lt;url-pattern&gt;</span>*.jsp<span class="code-tag">&lt;/url-pattern&gt;</span>
 <span class="code-tag">&lt;/filter-mapping&gt;</span></pre>
 </div></div>
-<p>Obviously you will want to set the URL pattern to match only the content you want to cache; this example will cache all JSP pages for 10 minutes in session scope.</p>
+<p>Obviously you will want to set the URL pattern to match only the content you want to cache; this example will cache all JSP pages for 10 minutes in session scope. The default duration is one hour and the default scope for the cache is application scope. </p>
 
-<p>The default duration is one hour and the default scope for the cache is application scope. You can change these special CacheFilter settings using the following initialization parameters.</p>
+<p>If the <a href="#CacheFilter-ICacheKeyProvider" title="ICacheKeyProvider on CacheFilter">ICacheKeyProvider</a> parameter isn't set, the CacheFilter will use the HTTP request URI and the QueryString to create the cache key. </p>
+
+<p>You can change the CacheFilter settings using the following initialization parameters.</p>
 
 <h4><a name="CacheFilter-Parameter%3Atime"></a><a name="CacheFilter-time"></a>Parameter: time</h4>
 

docs/wiki/Feature List.html

 
 <ul>
 	<li>A Servlet 2.3 Filter allows for caching of entire pages and generated binary files (like dynamically created images or PDF files).</li>
+	<li>Caching of binary files is extremely useful when they are generated dynamically and the average creation time is long.</li>
+	<li>The <a href="CacheFilter.html" title="CacheFilter">CacheFilter</a> is using the last modified header to reduce excellently the transaction overhead and server load which speed ups the server response time.</li>
 </ul>
 
 

docs/wiki/Home.html

     <div class="blogHeading" style="margin-top: 0px; padding-top: 0px"><a style="text-decoration: none; color: black" href="/display/CACHE/2006/07/22/OSCache+2.3.2+Released">OSCache 2.3.2 Released</a></div>
 
     <div class="pagesubheading">
-                    </div>
+                    Last changed: Jul 23, 2006 06:58 by     <a href="/display/~lars%2Bt">Lars Torunski</a>                    </div>
         <div class="wiki-content">
          <p><span class="nobr"><a href="http://wiki.opensymphony.com/display/CACHE/OSCache+2.3.2" title="Visit page outside Confluence" rel="nofollow">Version 2.3.2<sup><img class="rendericon" src="/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> of the popular open-source J2EE cache was released on 23rd July 2006. </p>
 

docs/wiki/index.html

                                  <img src="/images/icons/docs_16.gif" height="16" width="16" border="0" align="absmiddle" title="API Usage"/>
                          <a href="/display/CACHE/API+Usage">API Usage</a>
         <br />
-             <div class="smalltext" style="margin: 0 0 0 36px">Beside the JSP tag library JSP Tags and the CacheFilter you can use OSCache through its straightforward API. E.g.  you can use the GeneralCacheAdministrator http://www.opensymphony.com/oscache/api/com/opensymphony/oscache/general/GeneralCacheAdministrator.html to create ... </div>
+             <div class="smalltext" style="margin: 0 0 0 36px">Beside the JSP tag library JSP Tags and the CacheFilter you can use OSCache through its straightforward API. You can use the GeneralCacheAdministrator http://www.opensymphony.com/oscache/api/com/opensymphony/oscache/general/GeneralCacheAdministrator.html to create, flush ... </div>
         </td>
                                       </tr><tr valign="top">
                            <td><h4 style="margin-top: 0px"><a name="index-B"></a>B</h4>
                                  <img src="/images/icons/docs_16.gif" height="16" width="16" border="0" align="absmiddle" title="Feature List"/>
                          <a href="/display/CACHE/Feature+List">Feature List</a>
         <br />
-             <div class="smalltext" style="margin: 0 0 0 36px">OSCache Features  Fast inmemory caching    OSCache allows you to execute dynamic content periodically (eg every 30 minutes) rather than every request and store the result in memory. Each further request is served directly from the memory ... </div>
+             <div class="smalltext" style="margin: 0 0 0 36px">OSCache Features   Fast inmemory caching     OSCache allows you to execute dynamic content periodically (eg every 30 minutes) rather than every request and store the result in memory. Each further request is served directly from the memory ... </div>
         </td>
                                       <td><h4 style="margin-top: 0px"><a name="index-G"></a>G</h4>
         </td>