Created
June 15, 2010 20:51
-
-
Save John2496/439714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
/** | |
* Abstract controller class for automatic templating and view mapping. | |
* | |
* @package Controller | |
* @author John Himmelman ([email protected]) | |
*/ | |
abstract class Controller_ViewMapper_Cache extends Controller_ViewMapper | |
{ | |
public $use_cache = FALSE; | |
public $cache_id = ''; | |
public $cache_lifetime = 60; | |
public function after() | |
{ | |
$ret = NULL; | |
if ($this->use_cache) | |
{ | |
$this->cache_id = $this->request->controller . '-' . $this->request->action; | |
$content = kohana::cache($this->cache_id); | |
if ($content) | |
{ | |
$this->request->response = $content; | |
} | |
else | |
{ | |
$ret = parent::after(); | |
kohana::cache($this->cache_id, $this->request->response, $this->cache_lifetime); | |
} | |
} | |
else | |
{ | |
$ret = parent::after(); | |
} | |
return $ret; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment