PHP DB Cache Overview
This is a class to cache the results of database queries in a simple XML format, which uses a mixture of the query, and the tables involved, to create filenames and directories in which the cached results are stored.
Cache has two main funcitons, search and create.
Usage
You do not need to cache all the queries you make, so only use caching when you really need to. For a query that you want to cache, first use search to check whether it already exists. If it does, then use that data. Otherwise, execute and do whatever you want to with your query, then call create so that a cached copy of your query is available, e.g.;
include ("cache_xml.php");
$cache = new Cache;
$query = "SELECT id, name FROM Users";
$tables = "Users";
// See if a cached copy exists, if not, process the query and create the cache after
if($nodes = $cache->search( $query, $tables ) ) {
// A cached copy exists, so process it...
print_r($nodes);
} else {
// Retrieve the results and process them...
$result = mysql_query( $query, $link_id );
// etc
// Then create a cached copy of the query
$cache->create( $query, $tables, $result );
} //endif
Installation
However, DOM XML functions are used, and PHP needs to be compiled accordingly. You may want to alter the directory where the cached files are stored, adn you can do this by editing the script directly. The variable $this->cache_dir currently points to C:\temp\, and I would recommend changing this before attempting to do anything else.
Download
PHP database caching can be downloaded from here;
Download PHP database caching
Version 2
Version 2 isn't planned, but flames, feedback and questions can be directed to me, here.