From adb899a14b65e553d24eabd9de0d38c6dd5d340c Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 10 Oct 2006 23:11:33 +0000 Subject: --- user_guide/database/caching.html | 46 +++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index 05c6b3304..0e31eac2d 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -81,7 +81,7 @@ when caching is enabled. Do NOT load this class manually.

  • Enable the caching feature, either globally by setting the preference in your application/config/database.php file, or manually as described below.
  • -

    Once enabled, caching will happen automatically whenever a web pages that contains database queries is loaded.

    +

    Once enabled, caching will happen automatically whenever a page is loaded that contains database queries.

    How Does Caching Work?

    @@ -103,11 +103,11 @@ events take place, like when you've added new information to your database.

    Getting a performance gain as a result of caching depends on many factors. If you have a highly optimized database under very little load, you probably won't see a performance boost. -If your database is under heavy use you probably will see an improved response, assuming your filesystem is not +If your database is under heavy use you probably will see an improved response, assuming your file-system is not overly taxed. Remember that caching simply changes how your information is retrieved, shifting it from being a database -operation to a filesystem one.

    +operation to a file-system one.

    -

    In some clustered server environments, for example, caching may be detrimental since filesystem operations are so intense. +

    In some clustered server environments, for example, caching may be detrimental since file-system operations are so intense. On single servers in shared environments, caching will probably be beneficial. Unfortunately there is no single answer to the question of whether you should cache your database. It really depends on your situation.

    @@ -119,7 +119,7 @@ first two segments of your URI (the controller class name and function name).

    For example, let's say you have a controller called blog with a function called comments that contains three queries. The caching system will create a cache folder -called blog_comments, into which it will write three cache files.

    +called blog+comments, into which it will write three cache files.

    If you use dynamic queries that change based on information in your URI (when using pagination, for example), each instance of the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have @@ -158,8 +158,44 @@ pertain to run-time operations.

    +

    $this->db->cache_on()  /   $this->db->cache_off()

    +

    Manually enables/disables caching. This can be useful if you want to +keep certain queries from being cached. Example:

    + +// 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"); +
    + + +

    $this->db->cache_delete()

    + +

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

    + +

    The caching system saves your cache files to folders that correspond to the URI of the page you are viewing. For example, if you are viewing +a page at www.your-site.com/index.php/blog/comments, the caching system will put all cache files associated with it in a folder +called blog+comments. To delete those particular cache files you will use:

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

    If you do not use any parameters the current URI will be used when determining what should be cleared.

    + + +

    $this->db->cache_delete_all()

    + +

    Clears all existing cache files. Example:

    + +$this->db->cache_delete_all(); -- cgit v1.2.3-24-g4f1b