Description
When a declarative API (cache annotations) is used then a container generates a cache key.
When a cache is configured as read-through or write-through then the generated key is passed to a CacheLoader/CacheWriter.
However there is a mismatch: The key is generated by a container however the CacheLoader/CacheWriter are typically implemented by end-users -> the CacheLoader
has no good way to access arguments used during invocation of the annotated method. All it has is just the generated key.
A possible workaround is to always always use an explicit CacheKeyGenerator
and never use the default one -> a user has a full control of the generated cache key and can get back the arguments in the MapLoader
code. Unfortunately this is tedious as CacheKeyGenerator
is a very low-level API and it renders the default generator useless.
I'm not sure what's the best solution here:
- Perhaps the spec should mandate a concrete implementation of the default (composed?) key.
The implementation could have an extra method to get back the arguments encapsulated by this key? However this approach goes against the idea of generated key relaxation. - Alternatively the spec could provides a bunch of static method for introspection of the generated cache keys?
- Anything else?
Related to #313