StartMVC开发手册

可以快速上手的开发文档

文件缓存

缓存默认的方式为file文件缓存:

文件缓存的使用

// File方式

if(!$data = $this->cache->get('a')){    // 从缓存a中获取缓存数据,如果不存在或过期则返回false
    $data = foo($bar);    // foo($bar)获取数据
    $this->cache->set('a', $data, 3600);    // 将数据存入缓存a,第三个参数是有效期时间,单位秒,默认是3600
}
var_dump($data);
 
$this->cache->set('b', $data2);
$this->cache->del('b');    // 删除缓存b
$this->cache->clear();    // 删除所有缓存