I am working on setting up Spring Cache support for my Java application. I want a way to set a global @CacheConfig for my entire project because I want all cache operations in the application to use the exact same cache name and custom KeyGenerator implementation. I was hoping that I could annotate some global configuration class or my CacheManager
with @CacheConfig
, but it looks like @CacheConfig
is only meant as configuration for the class of the method with the Cache Annotation. Thus, I would need to use the same exact @CacheConfig
annotation definition for every class using Spring Cache operations.
A workaround that I'm going to use in the meanwhile is implement my own meta-annotation of Spring Cache annotations such as @Cacheable
, so that the same exact name
and keyGenerator
will be used for all cache operations. But, there must be a better way to do this than using custom annotations. If I ever run into the situation where I want to use a Cache named something other than "default", then I'm going to run into trouble with my custom annotation.
Any ideas? Thank you.