Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use caching using database in codeigniter

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.63k
    Comment on it

    Enabling caching .

    Caching is enabled in three step.
    1) Create a writable directory on your server where you want strored the cache files.
    2) Set the path to your cache folder in your application/config/database.php file.
    3) Enable the caching feature, either globally by setting the preference in your application/config/database.php file.
    Important Note: This class is initialized automatically by the database driver when caching is enabled. Do NOT load this class manually.

    References functions.

    $this->db->cache_on()  /   $this->db->cache_off()
    // Turn caching on
    $this->db->cache_on();
    $query = $this->db->query("SELECT * FROM mytable");
    
    // Turn caching off for this one query
    $this->db->cache_off();
    $query = $this->db->query("SELECT * FROM members WHERE member_id = '$current_user'");
    
    // Turn caching back on
    $this->db->cache_on();
    $query = $this->db->query("SELECT * FROM another_table");
    

    Delete caching files.
    Deletes the cache files associated with a particular page. This is useful if you need to clear caching after you update your database.

    $this->db->cache_delete();
    $this->db->cache_delete('blog', 'comments');
    $this->db->cache_delete_all();

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: