Cache Invalidation

I need to clear cache from the servers of the application through code.

Now, whenever we do API calls, the server seems to misbehave and return incorrect results. To fix that, we need to go and manually clear the application cache. 

Now, I need to make this feature in the code such that as soon as the application realizes that there is some "dirty" data in the servers, it automatically clears the cache and the application behaves properly. 

I know I need to use the "EspaceInvalidateCache" action, but how do I identify that there are some dirty records?

Is there any particular entity in OutSystems that stores this information?

NOTE: We do need to store the cache in the servers, i.e. we cannot just "NOT STORE" the cache in the first place.


Hi Prakhar,

What do you mean by  "dirty" data can you give us some example?

Best Regards

Devendra

Outsystems has some Front-end servers that store the most frequently used values (cache) in it for regular use of the application. It makes data fetching a bit fast. 

When a particular value in the Front-End server (cache server) becomes old, i.e. the back-end server has the updated value and the Front-end server doesn't have the same value as back-end, then the value in the Front-end server cannot be used and it is marked as "dirty". 

I need to figure out such dirty values and delete them using code.

Regards

Hi Prakhar.

Thanks for the explanation. What is your Cache time? and what all objects your are caching?

Bets Regards

Devendra


Hi Devendra, 

Everything is set to default and we are only caching API responses.

Regards

Hi Prakhar,

One possible solution is to keep the API current cache data in a entity (just for validation purpose) and create a Timer that will run in every 5 minutes and it will check the cache data from entity and API and If doesn't match then a Boolean flag is updated like IsDirty = True and from the application you can call the EspaceInvalidateCache

It would also depend how frequently your API data is changed because calling EspaceInvalidateCache frequently is also not good practice .May be depending on your API data changes you can define the  Cache time of the API

Best Regards

Devendra

I think you can refer Espace_runtime entity under System. It store all runtime information about the espace. But what is the meaning of misbehave in your case, also what is dirty data.  Because I think invalidate cache again and again is not a good idea.


Kindly read the documentation from here. Even I don't understand much.

"If an old cached value is found, cache invalidation marks it as "dirty", and fetches new values from their original location. " This is what is says. 

Regards

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.