Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Call Service on Cache Expiry

Hey Guys,

I have a requirement to automatically refresh token on/or before cache expiry. How do we do automatically trigger token endpoint on cache expiry ? Any other better suggestions also welcome.

regards,

GR

 

 

 

Solved Solved
0 2 198
1 ACCEPTED SOLUTION

How do we do automatically trigger token endpoint on cache expiry

You can't. Apigee doesn't fire an event when a cache item expires. If you want something like that , you'd need to run your own redis (or similar) and build a service.

If it's token expiry, then... maybe there are workarounds. One obvious option is to incur the cost of getting a new token, when the current token is expired, inline with the request. If you get 1000 requests per minute, and the token lasts an hour, then one request out of 60,000 would incur the cost of getting a new token.

The other option I can think of is... when you get a token, also set up a Scheduled Task (this is outside of Apigee!) to fire prior to expiration. That scheduled task will call the token endpoint to get a new token, out-of-band with respect to any API request being handled by Apigee. And then cache it.

View solution in original post

2 REPLIES 2

How do we do automatically trigger token endpoint on cache expiry

You can't. Apigee doesn't fire an event when a cache item expires. If you want something like that , you'd need to run your own redis (or similar) and build a service.

If it's token expiry, then... maybe there are workarounds. One obvious option is to incur the cost of getting a new token, when the current token is expired, inline with the request. If you get 1000 requests per minute, and the token lasts an hour, then one request out of 60,000 would incur the cost of getting a new token.

The other option I can think of is... when you get a token, also set up a Scheduled Task (this is outside of Apigee!) to fire prior to expiration. That scheduled task will call the token endpoint to get a new token, out-of-band with respect to any API request being handled by Apigee. And then cache it.

thanks for the confirmation !!