Class CachedAspect
- All Implemented Interfaces:
org.aopalliance.aop.Advice,org.aopalliance.intercept.Interceptor,org.aopalliance.intercept.MethodInterceptor
Cached using Spring AOP. Intercepts calls to any
@Cached-annotated method, and either returns the cached result or
runs the method and caches what it returns.
Notably, this class never needs to figure out "what method am I currently
in" by walking the stack -- JoinPoint.getSignature()
hands over the Method object directly, because Spring AOP is
already intercepting the call at the one point where that's known for
free. This is the general reason AOP-based caching (Spring's own
@Cacheable, JSR-107's @CacheResult, this class) never
needs StackWalker-style introspection.
Cache key construction: the key combines the target
class name, method name, and Arrays.deepHashCode(Object[]) of the
arguments -- not their toString(). This means correctness depends
on the arguments having proper, value-based equals()/
hashCode() (true for String, boxed numerics, enums, records, and
most well-behaved value types). As with any hash-based key, there is a
theoretical (astronomically unlikely) chance of two different argument
combinations colliding on the same hash and sharing a cache entry. If a
particular method's correctness can't tolerate that risk at all, don't
annotate it -- cache it manually instead.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CachedAspect
-
-
Method Details
-
invoke
- Specified by:
invokein interfaceorg.aopalliance.intercept.MethodInterceptor- Throws:
Throwable
-