Code Igniter User Guide Version 1.5.0


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. 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.

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

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

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. 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.