示例#1
0
final class ApcDBCache extends BaseCache
{
    public function __construct()
    {
        if (!is_callable("apc_add")) {
            throw new Exception("There is not APC module");
        }
    }
    public function store($key, $records, $ttl = 3600)
    {
        return apc_store($key, $records, $ttl);
    }
    public function get($key, &$records)
    {
        $records = apc_fetch($key, $success);
        return $success;
    }
    public function delete($key)
    {
        return apc_delete($key);
    }
}
DB::setCacheHandler(new ApcDBCache());
/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: sw=4 ts=4 fdm=marker
 * vim<600: sw=4 ts=4
 */
示例#2
0
        return $file;
    }
}
class FileCache
{
    public $start_date;
    public $ttl = 3600;
    public $data = array();
    function __construct($data = array())
    {
        $this->start_date = time();
        $this->setData($data);
    }
    function setData(array $data)
    {
        $this->data = $data;
    }
    function isValid()
    {
        return $this->start_date + $this->ttl > time();
    }
}
DB::setCacheHandler(new FileDBCache());
/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: sw=4 ts=4 fdm=marker
 * vim<600: sw=4 ts=4
 */