Is there a way to call the "Clear a cache entry" API?

To call the "Clear a cache entry" API below, you need to specify the complete CacheKey:

http://apigee.com/docs/management/apis/post/organizations/%7Borg_name%7D/environments/%7Benv_name%7D...

But the only way to get the complete CacheKey is to make an internal API call on an MP. Is there any other way to get the complete CacheKey, or should the "Clear a cache entry" API be removed from the doc?

Stephen

Solved Solved
0 12 1,913
1 ACCEPTED SOLUTION

@sgilson One way we can get the CacheKey is running a trace on the API which executing the cache policy and is also retrieving the response from the cache. Attached is the screenshot

279-screen-shot-2015-04-06-at-113137-am.png

View solution in original post

12 REPLIES 12

@sgilson One way we can get the CacheKey is running a trace on the API which executing the cache policy and is also retrieving the response from the cache. Attached is the screenshot

279-screen-shot-2015-04-06-at-113137-am.png

But this approach can only be done manually right ? Is there a way to get the cache keys programmatically ?

In order to do it programmatically, we need to have a public API call to get the cachekey which we do not expose yet.

@Sarthak if you are on an on-perm , you can get all the entries from C* (cache keyspace).

Hello Maruti ,

Could you please let know is there any documentation as to how we can retrieve cache entries from On-Premises ?

Regards,

Vaibhav

Not applicable

sgilson, @sarthak,

I always clear the caches if I know the key as the whole key that gets stored in C* is always in this format

$orgname__$envname____key (2 and 4 underscores(_))

It always work for me on R14 , give it a try on your env and see if it works .

Hi Maruti, how do you get the key though?

Stephen

I have a key which I want to clear and the complete entry which I need to pass in API will be

$orgname__$envname____key

For example , this is my Lookup cache and if I want to clear the entry it would be

entry = $orgname__$envname____$requestPath.pid

curl -v -u username:pwd https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/caches/{cache_... -X POST

<?xmlversion="1.0"encoding="UTF-8"standalone="yes"?>

<LookupCache enabled="true"continueOnError="false"async="false"name="LookupCache">

<DisplayName>LookupCache</DisplayName>

<FaultRules/>

<Properties/>

<CacheKey>

<KeyFragmentref="requestPath.pid"></KeyFragment>

</CacheKey>

<CacheResource>XYZCache</CacheResource>

<Scope>Global</Scope>

<AssignTo>storedCheck</AssignTo>

</LookupCache>

So you really have to do a bit of work to call this API. Either determine the key from a trace, or have insight into the way Cassanrda works. That doesn't sound like a common way to code an app, though.

@sgilson , I see the acceptance values or how they get stored in C* documented for various scopes here http://apigee.com/docs/api-services/reference/populate-cache-policy, Probably we should add this table to clear cache page .

I am also not sure how accurate the data is as for Global I have 4 underscores where as the table says only 2 . Probably we need to validate that again ?

Doesn't necessarily work all the time cause the cache key changes based on the scope defined in the cache policy. One can also define his/her own cache key by referring certain flow variables.

Agree , the above worked when the scope is 'Global' .

Complete key ( entry ) can vary from scope to scope and once you identify the pattern from C* you can always follow the same .