Skip to content

Commit ac52433

Browse files
author
Costin Leau
committed
+ update cache docs
1 parent 263dd55 commit ac52433

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spring-framework-reference/src/cache.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ public void loadBooks(InputStream batch)]]></programlisting>
248248
all the entires are removed in one operation as shown above. Note that the framework will ignore any key specified in this scenario as it does not apply (the entire cache is evicted not just
249249
one entry).</para>
250250

251+
<para>One can also indicate whether the eviction should occur after (the default) or before the method executes (the default) through the <literal>afterInvocation</literal> attribute.
252+
The former provides the same semantics as the rest of the annotations - once the method completes successfully, an action (in this case eviction) on the cache is executed. If the method does not
253+
execute (as it might be cached) or an exception is thrown, the eviction does not occur. The latter (<literal>afterInvocation=false</literal>) causes the eviction to occur always, before the method
254+
is invoked - this is useful in cases where the eviction does not need to be tied to the method outcome.</para>
255+
251256
<para>It is important to note that void methods can be used with <literal>@CacheEvict</literal> - as the methods act as triggers, the return values are ignored (as they don't interact with
252257
the cache) - this is not the case with <literal>@Cacheable</literal> which adds/update data into the cache and thus requires a result.</para>
253258
</section>

0 commit comments

Comments
 (0)