You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/09/08 17:26:56 UTC

cvs commit: jakarta-turbine-fulcrum/cache/xdocs changes.xml index.xml

epugh       2003/09/08 08:26:56

  Modified:    cache/xdocs index.xml
  Added:       cache/xdocs changes.xml
  Log:
  Update documentation for Cache service.  Fix example
  
  Revision  Changes    Path
  1.2       +57 -19    jakarta-turbine-fulcrum/cache/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/cache/xdocs/index.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.xml	20 Aug 2003 00:45:46 -0000	1.1
  +++ index.xml	8 Sep 2003 15:26:56 -0000	1.2
  @@ -34,31 +34,69 @@
         First, here is the role configuration.
       </p>
   
  -<source>
  -<![CDATA[
  -    <role
  -        name="org.apache.fulcrum.cache.GlobalCacheService"
  -        shorthand="cache"
  -        default-class="org.apache.fulcrum.cache.DefaultGlobalCacheService"/>
  -]]>
  -</source>
  -
  -  <p>
  -    And here is the configuration:
  -  </p>
  -<source>
  -
  -<![CDATA[
  -    <cache cacheInitialSize="20" cacheCheckFrequency="5"/>
  -]]>
  -</source>
  +    <source>
  +    <![CDATA[
  +        <role
  +            name="org.apache.fulcrum.cache.GlobalCacheService"
  +            shorthand="cache"
  +            default-class="org.apache.fulcrum.cache.DefaultGlobalCacheService"/>
  +    ]]>
  +    </source>
  +
  +      <p>
  +        And here is the configuration:
  +      </p>
  +    <source>
  +
  +    <![CDATA[
  +        <cache cacheInitialSize="20" cacheCheckFrequency="5"/>
  +    ]]>
  +    </source>
   
     </section>
   
     <section name="Usage">
  +
  +    <source><![CDATA[
  +
  +    GlobalCacheService gs = null;
  +    try
  +    {
  +        /*
  +         * Look for the item in the cache.
  +         * If it doesn't exist or the item is stale,
  +         * the cache will throw an exception.
  +         */
  +        gs = (GlobalCacheService)avalonComponentService.lookup(GlobalCacheService.ROLE)
  +
  +        CachedObject obj = gs.getObject("cached_object");
  +
  +        data.setMessage( data.getScreen() + " Got " +
  +            obj.getContents().toString() + " from global cache!" );
  +    }
  +    catch(ObjectExpiredException gone)
  +    {
  +        /*
  +         * Add the item to the cache.
  +         */
  +        gs.addObject("cached_object",
  +            new CachedObject("in_the_cache",5000));
  +
  +        data.setMessage( data.getScreen() +
  +            " Refreshed/or added new item to" +
  +            " the cache! Expires in 5 seconds" );
  +    }
  +
  +    ]]></source>
  +
       <p>
  +    You can also place an expiration time on your objects so the Service will
  +    automatically remove them when they expire. If you don't specify an expiration
  +    time, the Service uses 5 seconds. To see an example, look at the 
  +    test case <a href="xref-test/org/apache/fulcrum/cache/CacheTest.html">CacheTest</a>
       </p>
  -  </section>  
  +
  +  </section> 
   
   </body>
   </document>
  
  
  
  1.1                  jakarta-turbine-fulcrum/cache/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  <?xml version="1.0"?>
  <document>
    <properties>
      <title>Fulcrum Cache</title>
      <author email="epugh@upstate.com">Eric Pugh</author>
    </properties>
  
    <body>
      <release version="Not applicable" date="">
        <action dev="epugh" type="add">
          Integrated howto documentation on main page.
        </action>
      </release>
  
    </body>
  </document>