Improve unless condition in caching doc
See gh-1387
This commit is contained in:
committed by
Stephane Nicoll
parent
37d0db1615
commit
b426d847e6
@@ -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<Book> 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
|
||||
|
||||
Reference in New Issue
Block a user