File Cache

Use FileCache to accelerate the response of your report

employeeNumberfirstNamelastNamejobTitleextension
1,002 Diane Murphy President x5800
1,056 Mary Patterson VP Sales x4611
1,076 Jeff Firrelli VP Marketing x9273
1,088 William Patterson Sales Manager (APAC) x4871
1,102 Gerard Bondur Sale Manager (EMEA) x5408
1,143 Anthony Bow Sales Manager (NA) x5428
1,165 Leslie Jennings Sales Rep x3291
1,166 Leslie Thompson Sales Rep x4065
1,188 Julie Firrelli Sales Rep x2173
1,216 Steve Patterson Sales Rep x4334
1,286 Foon Yue Tseng Sales Rep x2248
1,323 George Vanauf Sales Rep x4102
1,337 Loui Bondur Sales Rep x6493
1,370 Gerard Hernandez Sales Rep x2028
1,401 Pamela Castillo Sales Rep x2759
1,501 Larry Bott Sales Rep x2311
1,504 Barry Jones Sales Rep x102
1,611 Andy Fixter Sales Rep x101
1,612 Peter Marsh Sales Rep x102
1,619 Tom King Sales Rep x103
1,621 Mami Nishi Sales Rep x101
1,625 Yoshimi Kato Sales Rep x102
1,702 Martin Gerard Sales Rep x2312

This example show you how to implement FileCache in your report. FileCache is the easiest and lowest cost way to significantly improve your report's speed and responsiveness. It is pretty simple, below code is all your need to add to your report:

<?php

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\cache\FileCache;

    function cacheSettings()
    {
        return array(
            "ttl"=>60,
        );
    }
    ...
}

The "ttl" is the Time To Live determine how many seconds the cache will be valid. Within the alive period, the report will not need to connect to your datasource or processing your data, it will retrieve datastore stored in cache to use.

This package is all about the speed and responsiveness of your reports. Let imagine your report need to pull large data from various sources to deliver the computed results. It takes time to load and process data. If many people go to your report at the same time, server may be overloaded.

Cache package will solve above problem. It will store the computed results temporarily in a period of time. If the report need to reload, results will be loaded from the cache, which results in lowering the load on your database and also the computation of your report. Utimately, it will increase the speed and responsiveness of your report.

<?php
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php
//Step 1: Load KoolReport
require_once "../../../../koolreport/autoload.php";

//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
    use \koolreport\cache\FileCache;

    function cacheSettings()
    {
        return array(
            "ttl"=>60,
        );
    }    

    function settings()
    {
        return array(
            "dataSources"=>array(
                "sakila_rental"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=automaker",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"
                ),
            )
        ); 
    }    
    protected function setup()
    {
        $this->src('automaker')
        ->query("SELECT employeeNumber, firstName,lastName,jobTitle, extension from employees")
        ->pipe($this->dataStore("employees"));
    } 

}
<?php
    use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">
    <div class="text-center">
        <h1>File Cache</h1>
        <p class="lead">
            Use FileCache to accelerate the response of your report
        </p>
    </div>
    <?php
    Table::create(array(
        "dataSource"=>$this->dataStore("employees"),
        "paging"=>true
    ));
    ?>
</div>

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport