Cached Datalayers - deleting a cache
Good Day,
I want to start using Cached Datalayers for our daily sales snapshot, which look straight forward and easy to use. However, I have a question about deleting a cache if required.
Here's the scenario: -
Our data warehouse is updated and built overnight so that the tables etc are ready for reporting by 6am. Of course, there could be errors with the build or delays for whatever reason.
At 6:15 a branch runs their MTD Sales Snapshot, which will not change until the following day when the warehouse gets updated again. As every branch user will view the report as they startup it makes sense to cache the queries. So, if the cache(s) are set to expire at 6am then the first staff member to run the report will force a requery and recache whilst everyone thereafter will use the latest cache. All good.
But, what happens if the overnight build is delayed for some reason? After 6am the first user will force a refresh but the data will be incorrect because the build is still happening. But, now the cache has been generated so how can I force a refresh?
Ideally, I should be able to create a task that I can run which kills all the cached reports or updates the cache time. Even better would be for the report check the build and force a refresh of the cache.
Any ideas?
-
Your data warehouse workflow should trigger a Logi process task which builds the cache. Most properties within a DataLayer.Cache can be tokenized, including the "Expiration Now" properties. Set it to "@Request.ExpirationNow~" on all of the DataLayer.Cache elements that way you can simply run the process task with "ExpirationNow=True" to renew all cached datalayers built within the process task.
Another more complex option would be to set the Expiration Time Span to 48 hours but tokenize the Cache Key with a Session token. This session token would be based on some value written within a database for "in-process" cache key for whenever your data warehouse process completes. Then the data warehouse process should run the process task which builds your cache using this in-process CacheKey value. At the end of this process update the database value used by the application for the "live" cache key to the one used for "in-process". Your application will now store two versions of the cache for each 24 hour period. In your application's startup process set a Session token to the "live" Cache Key value found in the database. This should eliminate situations where a user runs a report after the cache has expired, but before the new cache is built, because they will still retrieve the old "live" cache key during their startup process. You could then periodically check within the user's session to see if the new cache key is available.0
Please sign in to leave a comment.
Comments
1 comment