为什么 Codeigniter 缓存数据库在 get 查询中不起作用?

Why Codeigniter cache db is not working in get query?

您好,我只需要在我的 CI 应用程序中缓存一个查询。 我不明白现在该怎么办。例如,我在 config/database.php

中有这个
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = APPPATH . 'cache';

这是我的模型:

public function get_languages() {
        $this->db->cache_on();
        $this->db->save_queries = TRUE;
        log_message("error", "getLanguages!!!!!!!!!!!!!");
        $this->db->from('tbl_language'); 
        $result = $this->db->get();
        $results = $result->result_array();
        log_message("error", $this->db->last_query());
        return $results;
}

我总是看到查询是在数据库中执行的。 请帮忙!怎么了?

下面的代码对我有用!

public function get_languages() {
        $this->db->cache_on();
        $this->db->save_queries = TRUE;
        log_message("error", "getLanguages!!!!!!!!!!!!!");
        $this->db->from('tbl_language'); 
        $result = $this->db->get();
        $results = $result->result_array();
        var_dump($results);//print for checking
        $count = $result->num_rows();
        log_message("error", $this->db->last_query());
        if($count>0)
        {
            foreach($results as $list)
            {
                echo $list['id'];
            }           
        }
}