Cache_Lite とか2
Cache_Lite とか
ですが、cacheオブジェクト生成の箇所があまりにあまりなのでちょっとだけ直したものを。
[php]
<?php
require_once('Cache/Lite.php');
class Base {
var $cachLifeTime = 300;
function _call($name, $args) {
$class = get_class($this);
if (preg_match('/^(.+)c$/', $name, $m)) {
$func = $m[1];
$key = $class . ':' . $func . ':' . serialize($args);
$cache = $this->getCache();
$cache->setCacheLifeTime($this->cacheLifeTime);
$res = $cache->get($key);
if ($res !== FALSE) {
return $res;
}
$res = call_user_func_array(array($this, $func), $args);
$cache->save($res, $key);
return $res;
}
$class = get_class($this);
echo("not found function {$class}::{$name}");
}
function getCache() {
static $cache = null;
if ($cache === null) {
$cache = new Cache_Lite(array(
'cacheDir' => '/tmp/',
'automaticSerialization' => TRUE,
));
}
return $cache;
}
}[/php]