1. class indexController extends grace{
    2. //根据缓存情况设置、读取缓存数据
    3. public function index(){
    4. $this->cache('test', 12, '__getData');
    5. p($this->test);
    6. }
    7.  
    8. echo '无缓存,进行查询...<br />';
    9. $db = db('persons');
    10. $persons = $db->fetchAll();
    11. return $persons;
    12. }
    13.  
    14. //删除指定的缓存
    15. $this->removeCache('test', '12');
    16. }
    17.  
    18. //清空缓存
    19. public function t2(){
    20. $this->clearCache();
    21. }