I am using Redis cache for caching (in a Spring boot application). I want to delete all keys starting with a Prefix String which is formed through the code and will look something like--> ABC:env:userAppId:
I want to drop all keys from Redis cache starting with that Prefix String.
I am passing the prefix String to the method that calls the Redis drop method:
void dropCache(){
//Calculate the prefix String
rediHelper.dropCache(prefixString) ;
}
The Redis Helper method looks like:
@CacheEvict(value= "user", key="#objectKey")
void dropCache(String objectKey){}
I already tried following and none of them worked:
- Suffixing the * : @CacheEvict(value= "user", key="#objectKey*")
- Using this approach: @CacheEvict(value= "user", key="#{objectKey*}")
None of these have worked.
Also,
- If this can be solved using @CacheEvict?
- If not possible using @CacheEvict then how it can be achieved?