Purpose of this module is to provide a cache api with differents providers. Currently the following cache providers are contained in the module:
simple hashmap
ehcache
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.
Look at the test case AbstractTestWineService
in the module spring-cache-test. A service called WineService
explains this. The default implementation has two requirements :
WineDao (DAO layer)
CacheBuilder
CacheBuilder can build a cache for the bean you ask (in the sample it’s Wine) cacheBuilder.getCache( Wine.class ) This will use the following algorithm to provide the Cache implementation :
search the Spring Cache with roleHint Wine.class.getName()
if not found : lookup the Spring component Cache with name cache#default
if not found : return NoCacheCache
implementation in order to prevent NPE
spring-cache-api
spring-cache-test
spring-cache-providers