From 11c06c76e7a166228ef045c4d13c196bf964bd63 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 5 Oct 2006 05:12:27 +0000 Subject: --- user_guide/database/caching.html | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'user_guide/database/caching.html') diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index 02003b540..332efb615 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -67,30 +67,43 @@ Database Caching Class

The Database Caching Class contains functions that permit you to cache your queries.

Important:  This class is initialized automatically by the database driver -when caching is enabled, so you do NOT need to load this class manually. +when caching is enabled. Do NOT load this class manually. More info below...

How Does Caching Work?

-

When caching is enabled, anytime you run a "read" type query (SELECT) the result object will -be serialized and stored in a text file. Subsequent calls to that query will use the result from the cache file -rather then accessing your database.

+

When caching is enabled, anytime a "read" type query (SELECT) is run, the result object will +be serialized and stored in a text file on your server. Subsequent calls to that query will use the result from the cache file +rather then accessing your database. In other words, the first time a page is loaded a cache file will be written. +The next time the page is loaded the cached file will be used.

-

Code Igniter places your cached queries into sub-folders that are named based on the URI request. This allows -identical queries +

When a "write" type query (INSERT, UPDATE, etc.) is run , any cache files associated with the particular page being viewed +will be deleted automatically. In some cases you may need to update some data with every page load (user stats, for example). +In these cases you'll proabably want to manually disable caching just before running your "write" query, then re-enable it just +after. Otherwise, your site will be caught ina cycle of writing/deleting caches, creating more load then if you were not using +caching. More information on this will be found below.

-

If you run a "write" type query (INSERT, UPDATE, etc.) +

Although caching will reduce your database load, dealing with cache files does generate more +up-front processing and file-system operations, as cache files are created and read. Instead of accessing your database for information +text files are used.

-

Although caching queries reduces your database load, cached queries do require more -file-system operations, as cache files are created and read. Instead of accessing your database for information -text files are used. - -Whether you see a performance gain as a result of caching is dependant on many factors. +

Whether you see a performance gain as a result of caching is dependant on many factors. For example, 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 -overly taxed.

+overly taxed. In some clustered server environments caching may be detrimental since filesystem operations are so intense. +On single servers (particularly in shared enironments) 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.

+ +

Enabling Caching

+ +

Enabling caching requires three steps:

+ -- cgit v1.2.3-24-g4f1b