CodeIgniter Active Record Caching

In this tutorial you will learn about the CodeIgniter Active Record Caching and its application with practical example.

What Is Active Record Caching In CodeIgniter?

Active Record caching helps you to save some parts of your database queries so that you can reuse them at a later point in your script’s execution. Usually, when a query is executed all of the query related information is reset for the next query. Active record caching gives you way to prevent this reset, and reuse query information easily. Cached calls works in cumulative fashion, making 2 cached select() calls, and then 2 uncached select() calls, will result in 4 select() calls.

In CodeIgniter, we have following three active record caching functions –

$this->db->start_cache()

This function is used to start query caching.

$this->db->stop_cache()

This function is used to stop query caching.

$this->db->flush_cache()

This function is used to delete all items from the Active Record cache.

Example:-

Note:- The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set

In this tutorial we have learn about the CodeIgniter Active Record Caching and its application with practical example. I hope you will like this tutorial.