There are 3 main areas to look at (in my cache anyway).
ReadCache
It will check for the cache file (based on the name you pass in).
If that isn't present, it will return false.
If the cache file is present, it will read it and return it.
WriteCache
It will write the content to the filename passed in.
ClearCache
If you pass in a filename, it will remove only that file from the cache. If you don't pass in a filename, it will remove everything from the cache directory.
It's quite easy to use it.
<?php
/**
* Include the cache class file.
*/
require('/path/to/cache.php');
/**
* Set up the cache object.
*/
$cache_object = &new Cache('/path/to/cache/directory');
/**
* If we can read the cache, do it and then exit.
*/
if ($cache_contents = $cache_object->ReadCache('Index')) {
echo $cache_contents;
exit();
}
....
/**
* Write the cache out.
*/
$cache_object->WriteCache('Index', $page_contents);
?>
Nice and easy!
There are other pre-built cache systems, such as
Pear's Cache Lite and
Pear's Cache.
The only caveat in any cache system is making sure you clear it out at the right time.
This CMS is written using Object Oriented Programming, so it was easy for me to do this in the Create, Save and Delete methods.