blob: c4c864fc810a3b8c6638f26d0b4dda8af5381729 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<document>
<properties>
<title>Spring Cache</title>
<author email="olamy@codehaus.org">Olivier Lamy</author>
</properties>
<body>
<section name="Spring Cache">
<p>General Purpose is to provide a cache api with differents providers :
<ul>
<li>simple hashmap</li>
<li>ehcache</li>
<li>oscache</li>
</ul>
</p>
<subsection name="Use Case">
<p>Typical use case for this API could be the following : you have an functionnal API which create objects by using a requirement on a DAO plexus components. Before asking the DAO layer (webServices, Jdbc access ...), you want to ask if the data exists in a cache if yes the cached value is return if not the DAO layer is used and the result put in the cache for future use.
</p>
</subsection>
<subsection name="Test Case Sample">
<p>Look at he test case AbstractTestWineService in the module plexus-cache-test. A service called WineService explains this. The default implementation has two requirements :
<ul>
<li>WineDao (DAO layer)</li>
<li>CacheBuilder</li>
</ul>
</p>
<p>CacheBuilder can build a cache for the bean you ask (in the sample it's Wine)
<source>
cacheBuilder.getCache( Wine.class )
</source>
This will use the following algorithm to provide the Cache implementation :
<ul>
<li>search the Spring Cache with roleHint Wine.class.getName()</li>
<li>if not found : lookup the Spring component Cache with name cache#default</li>
<li>if not found : return NoCacheCache implementation in order to prevent NPE</li>
</ul>
</p>
</subsection>
</section>
<section name="Submodules" >
<ul>
#foreach( $module in $project.modules )
<li><a href="$module/index.html">$module</a></li>
#end
</ul>
</section>
</body>
</document>