Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 4 Query Caching

Hi all.
I'm trying to upgrade CI3 to CI4, and I have to to use query caching in CI3 to reuse my query.
Here is my code:

$sql = $this->db->start_cache()

$total = $sql->get()->num_rows();

$sql= $this->db->limit(10, 10)->get();

$data = $sql->result_array();
$total_per_limit = $sql->num_rows();


How can I do it in CI4?

Thanks in advance for help.

$result= $this->builder() .... ->get()->getResultArray();

save cache

  cache()->save("{$cachename}", $found, 300);

load cache

$result= cache("{$cachename}")

... function ...

if ( null === ($result= cache("{$cachename}")))

  $result= $this->builder() .... ->get()->getResultArray(); // do query

  cache()->save("{$cachename}", $found, 300); //save to cache


return $result;

Theme © iAndrew 2016 - Forum software by © MyBB