| <!DOCTYPE html> |
| <!-- |
| | Generated by Apache Maven Doxia Site Renderer 1.8.1 |
| | Rendered using Apache Maven Fluido Skin 1.6 |
| --> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta charset="UTF-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <meta name="author" content="Olivier Lamy" /> |
| <meta http-equiv="Content-Language" content="en" /> |
| <title>Spring Cache Component – Spring Cache</title> |
| <link rel="stylesheet" href="./css/apache-maven-fluido-1.6.min.css" /> |
| <link rel="stylesheet" href="./css/site.css" /> |
| <link rel="stylesheet" href="./css/print.css" media="print" /> |
| <script type="text/javascript" src="./js/apache-maven-fluido-1.6.min.js"></script> |
| <!-- Google Analytics --> |
| <script type="text/javascript"> |
| var _gaq = _gaq || []; |
| _gaq.push(['_setAccount', 'UA-140879-5']); |
| _gaq.push(['_trackPageview']); |
| (function() { |
| var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| })(); |
| </script> |
| </head> |
| <body class="topBarEnabled"> |
| <a href="https://github.com/apache/archiva"> |
| <img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;" |
| src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" |
| alt="Fork me on GitHub"> |
| </a> |
| <div id="topbar" class="navbar navbar-fixed-top "> |
| <div class="navbar-inner"> |
| <div class="container"><div class="nav-collapse"> |
| <ul class="nav"> |
| <li class="dropdown"> |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown">Modules <b class="caret"></b></a> |
| <ul class="dropdown-menu"> |
| <li><a href="spring-cache-api/index.html" title="Spring Cache API">Spring Cache API</a></li> |
| <li><a href="spring-cache-test/index.html" title="Spring Cache Tests">Spring Cache Tests</a></li> |
| <li><a href="spring-cache-providers/index.html" title="Spring Cache Providers">Spring Cache Providers</a></li> |
| </ul> |
| </li> |
| <li class="dropdown"> |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b class="caret"></b></a> |
| <ul class="dropdown-menu"> |
| <li><a href="http://www.apache.org/foundation/how-it-works.html" title="How Apache Works">How Apache Works</a></li> |
| <li><a href="http://www.apache.org/foundation/" title="Foundation">Foundation</a></li> |
| <li><a href="http://www.apache.org/foundation/sponsorship.html" title="Sponsoring Apache">Sponsoring Apache</a></li> |
| <li><a href="http://www.apache.org/foundation/thanks.html" title="Thanks">Thanks</a></li> |
| </ul> |
| </li> |
| <li class="dropdown"> |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a> |
| <ul class="dropdown-menu"> |
| <li class="dropdown-submenu"> |
| <a href="project-info.html" title="Project Information">Project Information</a> |
| <ul class="dropdown-menu"> |
| <li><a href="index.html" title="About">About</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <form id="search-form" action="https://www.google.com/search" method="get" class="navbar-search pull-right" > |
| <input value="http://archiva.apache.org/redback/components" name="sitesearch" type="hidden"/> |
| <input class="search-query" name="q" id="query" type="text" /> |
| </form> |
| <script type="text/javascript">asyncJs( 'https://cse.google.com/brand?form=search-form' )</script> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="container"> |
| <div id="banner"> |
| <div class="pull-left"><a href="http://archiva.apache.org/index.html" id="bannerLeft"><img src="http://archiva.apache.org/images/archiva.png" alt="Apache Archiva"/></a></div> |
| <div class="pull-right"><a href="http://www.apache.org/" id="bannerRight"><img src="http://www.apache.org/images/asf_logo_wide.png" alt="Apache Software Foundation"/></a></div> |
| <div class="clear"><hr/></div> |
| </div> |
| |
| <div id="breadcrumbs"> |
| <ul class="breadcrumb"> |
| <li class=""><a href="http://archiva.apache.org/index.html" class="externalLink" title="Archiva">Archiva</a><span class="divider">/</span></li> |
| <li class=""><a href="../index.html" title="Redback Components">Redback Components</a><span class="divider">/</span></li> |
| <li class=""><a href="index.html" title="Spring Cache">Spring Cache</a><span class="divider">/</span></li> |
| <li class="active ">Spring Cache</li> |
| <li id="projectVersion" class="pull-right">Version: 2.3-SNAPSHOT</li> |
| </ul> |
| </div> |
| <div id="bodyColumn" > |
| |
| |
| <div class="section"> |
| <h2><a name="Spring_Cache"></a>Spring Cache</h2> |
| |
| <p>General Purpose is to provide a cache api with differents providers : |
| </p> |
| <ul> |
| |
| <li>simple hashmap</li> |
| |
| <li>ehcache</li> |
| |
| <li>oscache</li> |
| </ul> |
| |
| |
| <div class="section"> |
| <h3><a name="Use_Case"></a>Use Case</h3> |
| |
| <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> |
| </div> |
| |
| <div class="section"> |
| <h3><a name="Test_Case_Sample"></a>Test Case Sample</h3> |
| |
| <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 : |
| </p> |
| <ul> |
| |
| <li>WineDao (DAO layer)</li> |
| |
| <li>CacheBuilder</li> |
| </ul> |
| |
| |
| <p>CacheBuilder can build a cache for the bean you ask (in the sample it's Wine) |
| </p> |
| <div class="source"><pre class="prettyprint"> |
| cacheBuilder.getCache( Wine.class ) |
| </pre></div> |
| 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> |
| |
| </div> |
| </div> |
| |
| <div class="section"> |
| <h2><a name="Submodules"></a>Submodules</h2> |
| |
| <ul> |
| |
| <li><a href="spring-cache-api/index.html">spring-cache-api</a></li> |
| |
| <li><a href="spring-cache-test/index.html">spring-cache-test</a></li> |
| |
| <li><a href="spring-cache-providers/index.html">spring-cache-providers</a></li> |
| </ul> |
| </div> |
| |
| |
| </div> |
| </div> |
| <hr/> |
| <footer> |
| <div class="container"> |
| <div class="row"> |
| <p>Copyright ©2006–2018 |
| <a href="http://www.apache.org/">The Apache Software Foundation</a>. |
| All rights reserved.</p> |
| </div> |
| <p id="poweredBy" class="pull-right"> <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a> |
| </p> |
| <div id="ohloh" class="pull-right"> |
| <script type="text/javascript" src="https://www.ohloh.net/p/6670/widgets/project_thin_badge.js"></script> |
| </div> |
| </div> |
| </footer> |
| </body> |
| </html> |