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

Can not update cache with the same key #46

Open
112921482 opened this issue Aug 24, 2017 · 4 comments
Open

Can not update cache with the same key #46

112921482 opened this issue Aug 24, 2017 · 4 comments

Comments

@112921482
Copy link

112921482 commented Aug 24, 2017

@Cacheable(value="token",key = { 1000 })
def getToken(){
this.updateToken()
}

@CachePut(value="token",key = {1000})
def updateToken(){
// some code get a result
*******
// some code get a result
return result;
}

"getToken" can not get the same after I run updateToken

@jameskleeh
Copy link
Contributor

Please upload an example application that reproduces the issue. Also what version?

@verglor
Copy link
Contributor

verglor commented May 7, 2018

The problem is that in version 4.0.0 of cache plugin the actual key in cache is CustomCacheKeyGenerator$TemporaryGrailsCacheKey - which in addition to simpleKey field (the key specified in @Cacheable annotation - in this case 1000) also contains targetClassName field and targetMethodName field (which in this case is 'getToken').

@CachePut nor @CacheEvict annotations could know what is the actual key in cache, since they don't know the name of method on which @Cacheable annotation was applied.

@mkobel
Copy link
Contributor

mkobel commented May 13, 2018

@112921482 and @verglor : you could check if your problem is solved with the manual key comparison in my merge request #51

@mkobel
Copy link
Contributor

mkobel commented May 31, 2018

@112921482 and @verglor the merge request #51 is merged into master with 13f8b05 so you could try if this solves your problem.

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

No branches or pull requests

4 participants