In my application I have multiple cacheable methods with multiple keys:
@Cacheable(cacheNames = "valueCodes", key = "{#value, #fieldId, #projectId}")
@Cacheable(cacheNames = "fieldNames", key = "{#field, #value, #projectId}")
@Cacheable(cacheNames = "qi", key = "{#langCode, #question, #projectId}")
@Cacheable(cacheNames = "fieldCodes", key = "{#name, #projectId}")
Now I want a cachevict method which cleares all the caches where only the #projectId key, which is a UUID, matches:
@CacheEvict(value = {"valueCodes", "fieldCodes", "qi"; "fieldCodes"}, key = "#projectId")
I've read in this article that this is not possible and that
Only the evict annotation's key regex matching more than one element in each of the cacheNames
I'm not really sure what they mean by that, but I guess it has something to do with using regex in SpEL.
So I started thinking about concatinating my keys into one key:
@Cacheable(cacheNames="cahceName", key="concat(#projectId).concat(#otherKey)")
and using regex to match all keys with the projectId followed by a wildcard. But I couldn't really find a way to do this.
Is what I'm trying to accomplish possible? If so, how do I do this?