Skip to content
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

SPR-8696, SPR-11316: custom key generator and cache manager #441

Closed
wants to merge 2 commits into from

Conversation

snicoll
Copy link
Member

@snicoll snicoll commented Jan 17, 2014

This change brings more features to the Cacheable, CacheEvict and CachePut annotations.

A custom CacheManager and/or KeyGenerator can be set per cache operation. If the parameter is set, we default as we did before to the global CacheManager and KeyGenerator respectively.

@snicoll
Copy link
Member Author

snicoll commented Feb 20, 2014

Note that the review of this pull request should probably be delayed a bit with the ongoing work on JSR-107 as it brings the concept of CacheResolver we may want to use to fix this particular issue. See comment on the related Jira issue.

This commit adds an extra parameter to the base @Cache method
annotations: keyGenerator. This parameter holds the name of the
KeyGenerator bean to use to compute the key for that specific
caching endpoint.

This gives therefore a third way to customize the key. These are:
1. Default KeyGenerator (global for all endpoints)
2. The 'key' attribute of the annotation, giving the SpEL expression to use
3. The 'keyGenerator' attribute of the annotation

The annotation attributes are therefore exclusive. Trying to specify
them both will result in an IllegalStateException.

The KeyGenerator to use for a given operation is cached on startup
so that multiple calls to it does not resolve the instance to use over and
over again.

Issue: SPR-10629
It is now possible to specify the CacheManager to use per operation.
The related cache annotation now has an extra attribute that defines
the name of the CacheManager bean to use.  The cache manager that
was previously used is therefore a 'default' cache manager (i.e. the
one to use if no custom cache manager has been set on the operation).

Issue: SPR-8696
@snicoll
Copy link
Member Author

snicoll commented Feb 27, 2014

CacheResolver integration in Spring's caching abstraction is handled in SPR-11490

@snicoll
Copy link
Member Author

snicoll commented Mar 31, 2014

This has been merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant