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

Cache evict not working with a custom key #51

Merged
merged 4 commits into from
May 31, 2018

Conversation

mkobel
Copy link
Contributor

@mkobel mkobel commented May 13, 2018

Caching and eviction does not work with the following example:

@Cacheable(value = 'basic', key = { key })
def doSomething(String key)  { ... }
@CacheEvict(value = 'basic', key = { key } )
def evictCache(String key) { .. }

According to my checks the problem is the@EqualsAndHashCode annotation creates a comparison where the method name is also part of the key. Therefore tha evict call cannot invalidate a cache entry.
The old manual implementation causes the same problem.
Therefore I modified the old manual implementation to skip the method name comparison if the provided keys are identical.
This is not a very nice solution but it solved the problem in my use cases.
A improved implementation might be tested using the added integration tests.

@mkobel
Copy link
Contributor Author

mkobel commented May 13, 2018

I assume the issue #46 is related to this problem.

@jeffscottbrown jeffscottbrown merged commit 13f8b05 into grails:master May 31, 2018
@puneetbehl puneetbehl added this to the 4.0.1 milestone Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants