Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
public function find($type = 'first', $params = array(),$cacheParams = array()){
$doQuery =true;
if( isset($cacheParams['cache']) && !empty($cacheParams['cache'])){
$cacheConfig = null;
if(isset($cacheParams['cacheConfig']) && !empty($cacheParams['cacheConfig'])){
$cacheConfig = $cacheParams['cacheConfig'];
}
$cacheName = $this->name.'-'.$cacheParams['cache'];
$data = Cache::read($cacheName,$cacheConfig);
if($data == false){
$data = parent::find($type,$params);
Cache::write($cacheName,$data,$cacheConfig);
}
$doQuery = false;
}
if($doQuery){
$data = parent::find($type,$params);
}
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.