Is wildcard keyfragment allowed in InvalidateCache policy

Not applicable

Wanted a way to invalidate all cache keys with the same prefix, regardless of cache key KeyFragment

This would be useful as our cache keys are prefixed with an ID as a prefix, it would be useful if we could invalidate all cache values for that ID in one shot

Thanks!

2 4 313
4 REPLIES 4

@Barry Tam ,

Yes, you can do that. We have management API using which you can clear all cache entries by prefix. You can find more about the API here.

Make sure you include the prefix in cache keys using the prefix element in populate cache / response cache policies.

Hope it helps. Keep us posted if any.

Thanks Anil, but I was more referring to the InvalidateCache policy itself so I can clear caches programmatically

I was thinking of using something like the below snippet, but was having issues getting it to work

<CacheKey>

<Prefix>barrytest</Prefix>

<KeyFragment>*</KeyFragment>

</CacheKey>

@Barry Tam , I don't think it is supported. See similar discussion here that happened between Apigee Engineering / docs team. Best bet is the above API, You can implement same as a service callout in your proxy if it works as expected.

@Anil Sagar @ Google, Can you please share sample xml to clear all cache entriles by prefix ?

Note: I want to clear cache of products which are having same productId.

I am using following cache key in response cache.

<CacheKey>

        <Prefix>testproduct</Prefix>
	<KeyFragment ref="productId" type="string"/>
        <KeyFragment ref="request.uri" type="string"/>

</CacheKey>
<br>

and following in invalidateCache.But it's not working.

<CacheKey>

        <Prefix>testproduct</Prefix>
	<KeyFragment ref="productId" type="string"/>
</CacheKey><br>