Update diese Antwort jetzt veraltet ist, für den Frühling 3.2 und später siehe Tech Trips answer, OP: Fühlen Sie sich frei, es als akzeptiert zu markieren.
Ich glaube nicht, dass es möglich ist (obwohl es bedingt Cache Räumung im Frühjahr, die beforeInvocation Satz falsch mit @CacheEvict
Parametern nach dem Methodenaufruf ausgeführt werden kann, der Standardwert ist) prüft die CacheAspectSupport
Klasse zeigt, dass Der zurückgegebene Wert wird nicht vor dem Aufruf inspectAfterCacheEvicts(ops.get(EVICT));
gespeichert.
protected Object execute(Invoker invoker, Object target, Method method, Object[] args) {
// check whether aspect is enabled
// to cope with cases where the AJ is pulled in automatically
if (!this.initialized) {
return invoker.invoke();
}
// get backing class
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
if (targetClass == null && target != null) {
targetClass = target.getClass();
}
final Collection<CacheOperation> cacheOp = getCacheOperationSource().getCacheOperations(method, targetClass);
// analyze caching information
if (!CollectionUtils.isEmpty(cacheOp)) {
Map<String, Collection<CacheOperationContext>> ops = createOperationContext(cacheOp, method, args, target, targetClass);
// start with evictions
inspectBeforeCacheEvicts(ops.get(EVICT));
// follow up with cacheable
CacheStatus status = inspectCacheables(ops.get(CACHEABLE));
Object retVal = null;
Map<CacheOperationContext, Object> updates = inspectCacheUpdates(ops.get(UPDATE));
if (status != null) {
if (status.updateRequired) {
updates.putAll(status.cUpdates);
}
// return cached object
else {
return status.retVal;
}
}
retVal = invoker.invoke();
inspectAfterCacheEvicts(ops.get(EVICT));
if (!updates.isEmpty()) {
update(updates, retVal);
}
return retVal;
}
return invoker.invoke();
}
Hallo, ich denke du solltest die Antwort von Tech Trip als akzeptiert akzeptieren, weil es relevanter für die aktuelle Version von Spring ist. –