0

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:

  1. Suffixing the * : @CacheEvict(value= "user", key="#objectKey*")
  2. Using this approach: @CacheEvict(value= "user", key="#{objectKey*}")

None of these have worked.

Also,

  1. If this can be solved using @CacheEvict?
  2. If not possible using @CacheEvict then how it can be achieved?

0 Answers0