Package com.easydesk.cache
Annotation Interface Cached
Marks a method's return value for automatic caching, backed by
GlobalCacheService. Applying this annotation is equivalent to
hand-writing the check-cache / call-method / store-result boilerplate
that the legacy code used to write out manually for every cached method.
Requirements for a method to be safely annotated:
- It must not return
void-- seeCachedAspectfor why. - Its return value should be
Serializable(or null). Non-serializable results are simply not cached (a warning is logged), so this is a soft requirement, not a hard failure. - Its arguments should have correct, value-based
equals()/hashCode()implementations. SeeCachedAspectfor how the cache key is built and what that implies. - It should be idempotent / side-effect-free for the given arguments -- a cached call means the method body may simply not run again until the entry expires.
@Cached(ttl = 60_000) // 1 minute
public Issue findIssue(String issueId) {
return IssuePeer.doSelectSingle(...);
}
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionlongHow long the result stays valid, in milliseconds.
-
Element Details
-
ttl
long ttlHow long the result stays valid, in milliseconds. Defaults toCachedObject.DEFAULT(30 minutes). UseCachedObject.FOREVERto never expire.- Default:
0L
-