grails-cache
grails-cache copied to clipboard
Can not update cache with the same key
@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
Please upload an example application that reproduces the issue. Also what version?
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.
@112921482 and @verglor : you could check if your problem is solved with the manual key comparison in my merge request #51
@112921482 and @verglor the merge request #51 is merged into master with 13f8b0556873e8cf7df4511094a3c517d75cc61b so you could try if this solves your problem.