InvalidateCache policy is clearing all cache entries

Hello!

I have a populate cache policy below:

maureenyogyog_0-1631067517589.png

and this is my invalidate cache policy:

maureenyogyog_1-1631067661139.png

I need to purge all cache entries by the key fragment <KeyFragment ref="clientInfo.cif" type="string"/> but what's happening is that all cache entries are being purged.

I also tried referencing an extracted variable instead of <KeyFragment ref="cache.request.uri" type="string"/> in my populate cache policy.

I also tried using scope instead of prefix but got the same result. 

What only worked is when I had the same key fragments in the populate cache and invalidate cache policies but this is not be applicable on the requirement.

Thanks!

 

 

1 4 143
4 REPLIES 4

Hi, @maureenyogyog 

I'm not using Cache Policies for my project, however, am I correctly understanding your question, that you are looking for selective cache purge, not full purge, right?

I mean, "InvalidateCache policy is clearing all cache entries" action seems valid feature, main purpose of this policy & works as expected, right?

thanks, best regards, Yermek

Thank you for the response. I implemented a workaround suggested by my colleague and it worked.

Hi, @maureenyogyog 

Glad that you found a solution. When time permits, could you share it here?

thanks, regards, Yermek

What only worked is when I had the same key fragments in the populate cache and invalidate cache policies but this is not be applicable on the requirement.

This is the expected behavior of these policies. I understand that this does not fit your requirements, but that's how the policies are designed and documented to work. You can invalidate cache entries only if you use the same key fragment that you used to populate the entries.