Skip to content

Commit 823dbdf

Browse files
author
Phillip Webb
committed
Merge pull request #379 from Xaerxess/fix-doc-cache
* fix-doc-cache: Fix Cache documentation
2 parents 7d3b649 + 03daf59 commit 823dbdf

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/reference/docbook/cache.xml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public Book findBook(ISBN isbn) {...}]]></programlisting>
113113
obvious when the target method has multiple arguments out of which only some are suitable for caching (while the rest are used only by the method logic). For example:</para>
114114

115115
<programlisting language="java"><![CDATA[@Cacheable("books")
116-
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed]]></programlisting>
116+
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)]]></programlisting>
117117

118118
<para>At first glance, while the two <literal>boolean</literal> arguments influence the way the book is found, they are no use for the cache. Further more what if only one of the two
119119
is important while the other is not?</para>
@@ -128,7 +128,7 @@ public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed]]></
128128
</para>
129129

130130
<programlisting language="java"><!-- select 'isbn' argument -->
131-
@Cacheable(value="books", <emphasis role="bold">key="#isbn"</emphasis>
131+
@Cacheable(value="books", <emphasis role="bold">key="#isbn")</emphasis>
132132
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
133133

134134
<!-- select nested property of a certain argument -->
@@ -298,7 +298,6 @@ public Book importBooks(String deposit, Date date)]]></programlisting>
298298
<programlisting language="java">@Configuration
299299
@EnableCaching
300300
public class AppConfig {
301-
302301
}</programlisting>
303302

304303
<para>Alternatively for XML configuration use the <literal>cache:annotation-driven</literal> element:</para>
@@ -506,8 +505,8 @@ public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)]]><
506505
<aop:config>
507506
<aop:advisor advice-ref="cacheAdvice" pointcut="execution(* x.y.BookService.*(..))"/>
508507
</aop:config>
509-
...
510-
// cache manager definition omitted
508+
509+
<!-- cache manager definition omitted -->
511510
]]>
512511
</programlisting>
513512

@@ -530,8 +529,8 @@ public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)]]><
530529
<title>Configuring the cache storage</title>
531530

532531
<para>Out of the box, the cache abstraction provides integration with two storages - one on top of the JDK <interfacename>ConcurrentMap</interfacename> and one
533-
for <link xl:href="ehcache.org">ehcache</link> library. To use them, one needs to simply declare an appropriate <interfacename>CacheManager</interfacename> - an entity that controls and manages
534-
<interfacename>Cache</interfacename>s and can be used to retrieve these for storage.</para>
532+
for <link xl:href="http://ehcache.org/">EhCache</link> library. To use them, one needs to simply declare an appropriate <interfacename>CacheManager</interfacename> - an entity that controls and
533+
manages <interfacename>Cache</interfacename>s and can be used to retrieve these for storage.</para>
535534

536535
<section xml:id="cache-store-configuration-jdk">
537536
<title>JDK <interfacename>ConcurrentMap</interfacename>-based <interfacename>Cache</interfacename></title>
@@ -542,15 +541,15 @@ public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)]]><
542541
<programlisting language="xml"><![CDATA[<!-- generic cache manager -->
543542
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
544543
<property name="caches">
545-
<set>
546-
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/>
547-
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="books"/>
548-
</set>
544+
<set>
545+
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/>
546+
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="books"/>
547+
</set>
549548
</property>
550549
</bean>]]></programlisting>
551550

552-
<para>The snippet above uses the <classname>SimpleCacheManager</classname> to create a <interfacename>CacheManager</interfacename> for the two, nested <interfacename>Concurrent</interfacename>
553-
<interfacename>Cache</interfacename> implementations named <emphasis>default</emphasis> and <emphasis>books</emphasis>.
551+
<para>The snippet above uses the <classname>SimpleCacheManager</classname> to create a <interfacename>CacheManager</interfacename> for the two nested <classname>ConcurrentMapCache</classname>
552+
instances named <emphasis>default</emphasis> and <emphasis>books</emphasis>.
554553
Note that the names are configured directly for each cache.</para>
555554

556555
<para>As the cache is created by the application, it is bound to its lifecycle, making it suitable for basic use cases, tests or simple applications. The cache scales well and is very fast
@@ -588,10 +587,12 @@ public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)]]><
588587
one can wire in a simple, dummy cache that performs no caching - that is, forces the cached methods to be executed every time:</para>
589588

590589
<programlisting language="xml"><![CDATA[<bean id="cacheManager" class="org.springframework.cache.support.CompositeCacheManager">
591-
<property name="cacheManagers"><list>
592-
<ref bean="jdkCache"/>
593-
<ref bean="gemfireCache"/>
594-
</list></property>
590+
<property name="cacheManagers">
591+
<list>
592+
<ref bean="jdkCache"/>
593+
<ref bean="gemfireCache"/>
594+
</list>
595+
</property>
595596
<property name="fallbackToNoOpCache" value="true"/>
596597
</bean>]]></programlisting>
597598

0 commit comments

Comments
 (0)