Good morning, we have a number of SQL and aggregate caches that are used to help speed up our application. Most of the time these work great but there are times when the data might change and we would want the query to re-execute.
I found the EspaceInvalidateCache action but that would invalidate all caches vs just the one we need done. Any suggestions? It would be great if we could control the cache setting via expression but that doesn't appear to be an option either.
Hi Josh,
AFAIK the only way to invalidate cache within an OutSystems application is by invalidating the cache of the entire module (using the EspaceInvalidateCache action).
I did a search on this forum in order to confirm my suspicion and I found this answer.
Hope this makes it more clear to you.
Regards,
Nordin
Thank you, I was hoping that there was another solution that was a better fit but I guess there isn't.
Encapsulate yor data fetchind in an action that has a boolean input parameter (non mandatory) that you call always at false to use your cached values.
When you want to recalculate the cached values call the action with the invalidateCache input as True, the change in the input value invalidates that action's cache and you do not have to invalidate the entire espace's cache.
https://success.outsystems.com/documentation/11/developing_an_application/use_data/caching/
Any cached element is evaluated again, and the resulting content is updated in the cache when:
This would create another cache entry with the optional input parameter but it does not invalidate the one already created without parameter. And the next time the action is called with the True parameter it would return the cached value created with parameter True if the cache is not expired yet. There isn't no easy way to invalidate a desired cache entry in OutSystems built-in mechanism as far as I can see. Storing last change timestamp in the site property is also against best practice as mentioned in the site property documentation. One possible solution would be to store the last change timestamp in the database, update it whenever the existing cache becomes outdated, query that value and pass to the action that runs SQL or aggregates as parameter.