Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 2.19 KB

ControlCaching.md

File metadata and controls

50 lines (33 loc) · 2.19 KB

Zermelo Reporting Engine Controlling Caching

A PHP reporting engine that works especially well with Laravel, built with love at CareSet Systems

Controlling Caching

Caching is controlled using theses two functions on your subclass of ZermeloReport

    /**
    * If the cache is not enabled, then every time the page is reloaded the entire report is re-processed and put into the cache table
    * So if you want to just run the report one time, and then load subsequent data from the cache, set this to return 'true';
    */
   public function isCacheEnabled(){
        return(false);
   }

    /**
    * This function does nothing if isCacheEnabled is returning false
    * But if the cache is enabled, then this will detail how long the report will be reloaded from the cache before the cache is regenerated by re-running the report SQL
    */
   public function howLongToCacheInSeconds(){
        return(1200); //twenty minutes by default
   }

Cache Indicator

There is a cache icon in the report toolbar. A tooltip displays the time the cache was last generated and the time the cache will expire. Click the cache icon to engage a dropdown with a menu item "clear cache" to force regenerateion of the cache and reload the report.

The basic sequence for serving a report on the back end is:

  • SQL in the report is run, and a table in the _zermelo cache directory holds the results.
  • A request comes in and either the request is served from the cache, or the SQL is re-run.
  • The request will be re-run, if the cache is "expired" or if caching is turned off.

Blue == The data you are seeing was loaded from a cache that was refreshed, immediately before it was sent to your browser

Red == The data you are seeing was loaded from the cache, that was not refreshed immediately before it was sent to your browser.

Yellow == The data you are seeing was loaded from the cache, and, if you asked it to, the server would now refresh the cache from the query. So if you want to load new data, just refresh the report

Flashing Yellow == Cache is about to expire, which means that the data was in the 'red' state, but is about to be in the 'yellow' state.