-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Introduce qualifier in @Cacheable for cache manager name [SPR-8696] #13338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Costin Leau commented A quick solution would be to use a decorating cache manager - CompositeCacheManager (which works as long as the cache definitions have different names). |
Chris Beams commented This is somewhat similar to the work in #11513 to allow executor qualification in |
Vincent DEVILLERS commented In order to fix this issue on one of my project, I did something like the AbstractRoutingDataSource:
|
Stéphane Nicoll commented See PR #441 |
Stéphane Nicoll commented Working on this issue from a different angle I am wondering if it wouldn't be more flexible to fix it differently. The issue here is that we want to be able per cache operation to resolve the right cache. The cache manager is actually only used for that. How about a How does that sound? |
Sam Brannen commented For situations like this, I find it's often beneficial to provide both a declarative and programmatic means for such functionality. For example, consider Of course, for caching it would make sense to be able to set the qualifier or resolver at the class level, not just at the method level. My $0.02, Sam |
Stéphane Nicoll commented If I understand you correctly, you mean keeping three attributes then: the name of the cache(s), the ref of the cacheManager and a ref to a The problem here is that I don't really see how it relates to your example. Specifying the cacheManager is exclusively used to resolve the specific cache name(s) against a different cache managers. I see it more has a third solution between If your point is that users wants to be able to manage different cache managers only declaratively, then yes, it makes sense to keep the 3 attributes. Setting at the class level is already implemented and pending review (but I asked some delay on the review as the work on JSR-107 is slightly changing things there). Thanks for the feedback Sam! |
Sam Brannen commented With regard to However, in the case of caching, each annotated class is actually a bean in the And if you introduce a |
Sam Brannen commented
Evaluating those attributes as SpEL expressions basically kills two birds with one stone. Whether or not we introduce dedicated resolver APIs is a different question. My main point in my original comment was that it is often a good idea to provide both a declarative and a programmatic mechanism for configuring such features, and these mechanisms should be available at the class-level as well as at the method-level, whereby method-level configuration overrides class-level configuration. Furthermore, any defaults configured via the XML namespace or So in the end you have three locations for declaring configuration for the cache manager, cache name resolution, and cache key generation. And this constellation represents a hierarchy like this:
Lower levels of configuration override higher levels. Regards, Sam |
Stéphane Nicoll commented Sam, please see #16115 for the programmatic mechanism. Thanks! |
Stéphane Nicoll commented It is now possible to specify the |
Gaetan Pitteloud opened SPR-8696 and commented
A qualifier attribute on
@Cacheable
would help to specify aCacheManager
in the scenario described in the referenced forum post and summarized here:Affects: 3.1 M2
Reference URL: http://forum.springsource.org/showthread.php?110853
Issue Links:
@Async
@CacheConfig
annotation to share class-level customizationsReferenced from: commits 2b89c1a, f06cad9
10 votes, 12 watchers
The text was updated successfully, but these errors were encountered: