/ Published in: PHP
Useful for controllers. Put this in your base class for easy caching on variable (GET, POST) dependent pages
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
protected function checkCacheData($prefix = FALSE, $vars = FALSE) { if($vars == FALSE) { $vars = input::instance()->get(); } if($prefix === FALSE) { $prefix = Router::$method; } $cacheKey = 'empty'; } else { } if($cachedData = $this->cache->get(Router::$controller'.'.$prefix.$cacheKey)) { return $cachedData; } else { return FALSE; } } protected function setCacheData($data, $prefix = FALSE, $vars = FALSE) { if($vars == FALSE) { $vars = input::instance()->get(); } if($prefix === FALSE) { $prefix = Router::$method; } $cacheKey = 'empty'; } else { } $this->cache->set(Router::$controller.'.'.$prefix.$cacheKey, $data); }