Caching not behaving consistently.

Not applicable

I have a requirement of keeping count of user request based on a key filed in payload and to throw error if the count increases beyond a limit. The count should reset in 30 minutes. I have used lookup and update cache to do this. The problem is when I am sending multiple requests one after other without any delay , the counter in the cache is not behaving consistently. The changes to cache done by one request is not visible to the subsequent request. If I send request with minor delay it always works fine. Is this problem with MPs not getting updated fast enough? How to resolve this?

0 2 174
2 REPLIES 2

@Ambarish Kumar Singh , See similar question asked here. That's not what it's really meant for. It's not a good idea to store counters in Apigee cache.

@Ambarish Kumar Singh

The caching internals doc :

http://docs.apigee.com/api-services/content/cache-internals

gives a perspective of how the L1 in-memory cache is visible only to the message processor process memory. If a request were to hit a particular mp and increment the counter, the incremented value would be visible only to that mp for 'sometime'. Like Anil says, It would not be a good idea to store counters in cache