From b426d847e696d1862229b91e18b8fdd496f6d175 Mon Sep 17 00:00:00 2001 From: "Michael J. Simons" Date: Thu, 13 Apr 2017 08:17:16 +0200 Subject: [PATCH 1/2] Improve unless condition in caching doc See gh-1387 --- src/docs/asciidoc/integration.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc index 20d4d249fc1..9941af8235e 100644 --- a/src/docs/asciidoc/integration.adoc +++ b/src/docs/asciidoc/integration.adoc @@ -8327,11 +8327,11 @@ supported wrapper so the previous example can be rewritten as follows: [source,java,indent=0] [subs="verbatim,quotes"] ---- - @Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result.hardback"**) + @Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result?.hardback"**) public Optional findBook(String name) ---- -Note that `result` still refers to `Book` and not `Optional`. +Note that `result` still refers to `Book` and not `Optional`. Also, we are using the safe navigation operator here to accommodate the fact that the `Optional` maybe empty. [[cache-spel-context]] ===== Available caching SpEL evaluation context From 7084bc293a320d710a0bbda648c0cb2453c7d660 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 13 Apr 2017 17:50:11 +0200 Subject: [PATCH 2/2] Polish "Improve unless condition in caching doc" Closes gh-1387 --- src/docs/asciidoc/integration.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc index 9941af8235e..2d3f3f54f67 100644 --- a/src/docs/asciidoc/integration.adoc +++ b/src/docs/asciidoc/integration.adoc @@ -8331,7 +8331,8 @@ supported wrapper so the previous example can be rewritten as follows: public Optional findBook(String name) ---- -Note that `result` still refers to `Book` and not `Optional`. Also, we are using the safe navigation operator here to accommodate the fact that the `Optional` maybe empty. +Note that `result` still refers to `Book` and not `Optional`. As it might be `null`, we +should use the safe navigation operator. [[cache-spel-context]] ===== Available caching SpEL evaluation context