From ac524330047a9bc88bb3950d01bf41719212b251 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Mon, 28 Nov 2011 14:00:26 +0000 Subject: [PATCH] + update cache docs --- spring-framework-reference/src/cache.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-framework-reference/src/cache.xml b/spring-framework-reference/src/cache.xml index f44fd43cf5..4bfab4d63b 100644 --- a/spring-framework-reference/src/cache.xml +++ b/spring-framework-reference/src/cache.xml @@ -248,6 +248,11 @@ public void loadBooks(InputStream batch)]]> 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 one entry). + One can also indicate whether the eviction should occur after (the default) or before the method executes (the default) through the afterInvocation attribute. + 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 + execute (as it might be cached) or an exception is thrown, the eviction does not occur. The latter (afterInvocation=false) causes the eviction to occur always, before the method + is invoked - this is useful in cases where the eviction does not need to be tied to the method outcome. + It is important to note that void methods can be used with @CacheEvict - as the methods act as triggers, the return values are ignored (as they don't interact with the cache) - this is not the case with @Cacheable which adds/update data into the cache and thus requires a result.