Let do some cool thing like this:
<?php
//AutoMaker.php
use \koolreport\dashboard\sources\MySQL;
use \koolreport\dashboard\caching\FileCache;
class AutoMaker extends MySQL
{
protected function onCreated()
{
$this->props([
"useCache"=>true,
]);
}
//Important that you provide cache object to datasource
protected function cache()
{
return $this->_useCache()?
FileCache::create()->ttl("5mins"):
null;
}
protected function connection()
{
return [
"connectionString"=>"mysql:host=localhost;dbname=automaker",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
];
}
}
Now by default your AutoMaker will use cache for 5 mins, but if a query that you do not want to be cache, do this:
AutoMaker::table("abc")->select(...)->useCache(false);
AutoMaker::rawSQL("...")->params([...])->useCache(false);
Let me know if you need further assistance.