|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2016 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
31 | 31 | *
|
32 | 32 | * <p>In contrast to the {@link Cacheable @Cacheable} annotation, this annotation
|
33 | 33 | * does not cause the advised method to be skipped. Rather, it always causes the
|
34 |
| - * method to be invoked and its result to be stored in the associated cache. Note |
| 34 | + * method to be invoked and its result to be stored in the associated cache if the |
| 35 | + * {@link #condition()} and {@link #unless()} expressions match accordingly. Note |
35 | 36 | * that Java8's {@code Optional} return types are automatically handled and its
|
36 | 37 | * content is stored in the cache if present.
|
37 | 38 | *
|
|
118 | 119 | /**
|
119 | 120 | * Spring Expression Language (SpEL) expression used for making the cache
|
120 | 121 | * put operation conditional.
|
| 122 | + * <p>This expression is evaluated after the method has been called due to the |
| 123 | + * nature of the put operation and can therefore refer to the {@code result}. |
121 | 124 | * <p>Default is {@code ""}, meaning the method result is always cached.
|
122 | 125 | * <p>The SpEL expression evaluates against a dedicated context that provides the
|
123 | 126 | * following meta-data:
|
124 | 127 | * <ul>
|
| 128 | + * <li>{@code #result} for a reference to the result of the method invocation. For |
| 129 | + * supported wrappers such as {@code Optional}, {@code #result} refers to the actual |
| 130 | + * object, not the wrapper</li> |
125 | 131 | * <li>{@code #root.method}, {@code #root.target}, and {@code #root.caches} for
|
126 | 132 | * references to the {@link java.lang.reflect.Method method}, target object, and
|
127 | 133 | * affected cache(s) respectively.</li>
|
|
136 | 142 |
|
137 | 143 | /**
|
138 | 144 | * Spring Expression Language (SpEL) expression used to veto the cache put operation.
|
139 |
| - * <p>Unlike {@link #condition}, this expression is evaluated after the method |
140 |
| - * has been called and can therefore refer to the {@code result}. |
141 | 145 | * <p>Default is {@code ""}, meaning that caching is never vetoed.
|
142 | 146 | * <p>The SpEL expression evaluates against a dedicated context that provides the
|
143 | 147 | * following meta-data:
|
|
0 commit comments