Below is what your buddy §intå× came up with. As always it is heavily documented. I will cover its uses below.

Php Code:


<?php
/**
* This file houses the cache class.  It will handle the caching of data for sql queries and markup.
*
* This file exists because I belive if you do something more than once you should find a way to 
* abstract it to a single call
* @package	 sqlCache
* @since	6/22/2007 22:10
* @author	 Russell Vance <[email protected]>
* @license	http://www.opensource.org/licenses/lgpl-2.1.php
*/

/**
* This class will generate cache files needed to speed up processing by the other classes
*
* The methods in this class are very powerful and should cut back time spent on sql queries
* @version	1.0.1
*/
class cacheMgr{
	
	/**
	* A numeric value for the hash type you want used in the naming of your files.
	* 1 = md5
	* 2 = sha1
	* The default is 1 md5
	*
	* @access	 public
	* @var		 integer
	*/
	public $hashType;
	
	/**
	* The number of seconds untill the cache file is expired.
	* 1 hrs = 3600
	* 6 hrs = 21600 etc, etc etc...
	*
	* @access	 public
	* @var		 integer
	*/
	public $expierTime;
	
	/**
	* A boolean value that tells the class wether or not to secure the cache file
	*
	* @access	 public
	* @var		boolean
	*/
	public $secure;
	
	/**
	* A string value that tells the the file extension you want for the cache files.  Defaults to '.tmp'
	*
	* @access	 public
	* @var		string
	*/
	public $fileExt;
	
	/**
	 * The full file path to your cache directory
	 * 
	 * @access	public
	 * @var		string
	 */
	public $cachePath;
	
	/**
	* This is the class constructor. Here you can set some options for your cached files.
	*
	* This constructor requires 3 parameters for the class to initialise.  You can see how to initialize 
	* the class in the example below:
	* <code>
	* //Example:
	*
	* $cache	 = new cacheMgr(1, 3600, true, 'php');
	* $cache2	= new cacheMgr('sha1', 86400, false, 'inc');
	*
	* </code>
	* The above code would create two new cacheMgr objects.  
	* The files with the first object created would be called and named with an 
	* md5 hash algorithm, They would expire after 1 hour and they would be made 
	* secure from outside viewers.
	*
	* The the files created from the second object would be named using the sha1 algorithm
	* They would expier after 24 hrs.  They would not be secured.  And they would use the 
	* default file extension.
	* @access	public
	* @param	integer		$hashType	options are 1, 2 or you can use the string identifiers md5, sha1.  <br />1 returns md5 hash named files, 2 returns sha1 hash named files
	* @param	integer		$expierTime	The number of seconds the cahe file is good for.  Defaults to 3600.
	* @param	boolean		$secure		True now direct web access.  False, allow web access to cache files.
	* @param	string		$fileExt	The cache file, file extension to use.
	* @return	void
	*/
	public function __construct($hashType = 1, $expierTime = 3600, $secure, $fileExt = 'tmp', $cachePath){
		$this->hashType		= $hashType;
		$this->expierTime	= (int)$expierTime;
		$this->secure		= (bool)$secure;
		$this->fileExt		= (string)$fileExt;
		$this->cachePath	= (string)$cachePath;
	}	
	
	/**
	* The class destructor
	*
	* Cleans up after the class and frees up memory.  No need to call it.
	* @access	public
	* @param	void
	* @return	void
	*/
	public function __destruct(){
		unset($this->hashType);
		unset($this->expierTime);
		unset($this->secure);
		unset($this->fileExt);
		unset($this->cachePath);
	}
	
	/**
	* This method will return the md5 or sha1 hash for a pain text string.
	*
	* This method exists so I do not have to define both hash methods in every cacheOutxxx method.
	* @access	private
	* @param	string		$plainText	The plain text string to be hashed
	* @return	string		On sucess, return the newly created hash value.  On fail return false.
	*/
	private function getHash($plainText){
		switch($this->hashType){
			case 1 || 'md5':
			default: 
				$newHash	= md5($plainText, false);
				break;
			case 2 || 'sha1':
				$newHash	= sha1($plainText, false);
				break;
		}
		return	$newHash;
	}
	
	/**
	* This method is used to cache out an enumerated array
	*
	* This method will cache out an enumerated array into a php script that can be called.
	* This is usually done to avoid having to do complex queries.  Note this method is only 
	* good for single demensional arrays at this time.
	* @access	public
	* @param	array				$array		An enumerated array to cache out
	* @param	string				$uniqueName	A string value passed in that will not be passed in for another cache.  Usualy $_GET parameters, or query keys from the sqlClass
	* @return	string|bool			On sucess returns the file name created.  On fail returns false.
	*/	
	public function cacheOutArray($array, $uniquieId){
		$uniquieId = str_replace(' ', '_', $uniquieId);
		if(is_array($array)){
			$outString = "\$".$uniquieId." = '".json_encode($array)."';";
		}
		if($fileName	 = $this->setCacheFile($uniquieId,$outString)){
			$retVal	 = $fileName;
		}else{
			$retVal	 = false;
		}
		return $retVal;
	}

	/**
	* This method returns data that has been cached out.
	*
	* This method accepts a unique identifier that would be used to name a cache file, generates
	* a hash of it and check if a file by that name exists.  If it does it will include the file.
	* @access	public
	* @uses		cache::cachePath Used to define the path to the cache directory
	* @uses		DS				A Constant for DIRECTORY_SEPERATOR
	* @param	string	$uniqueId	A unique identifier used to generate a hash value
	* @return	boolean	On sucess returns true.  On fail returns false.
	*/
	public function getCache($fileName){
		$filePath = $this->cachePath;
		if(file_exists($fileName)){
			@include_once($filePath.$fileName);
			return true;
		}else{
			return false;
		}
	}
	
	/**
	* This method returns an array that has been cached out.
	*
	* This method accepts a unique identifier that would be used to name a cache file, generates
	* a hash of it and check if a file by that name exists.  If it does it will include the file 
	* and return the array.
	* @access	public
	* @uses		cache::cachePath Used to define the path to the cache directory
	* @uses		DS				A Constant for DIRECTORY_SEPERATOR
	* @param	string	$uniqueId	A unique identifier used to generate a hash value
	* @return	array|boolean		Returns a stored array object on sucess. On fail returns false.
	*/
	public function getArrayCache($uniquieId){
		$uniquieId = str_replace(' ', '_', $uniquieId);
		$fileName = $this->getHash($uniquieId).'.'.$this->fileExt;
		$filePath = $this->cachePath;
		if(file_exists($filePath.$fileName)){
			include_once($filePath.$fileName);
			//print_r(json_decode($getOptions, true));
			$arr = json_decode( $$uniquieId, true );
			return $arr;
		}else{
			return false;
		}
	}

	/**
	* This method is used to generate a docblock for the cache file
	*
	* This method will auto gen a doc block for the cach file with the time it was created in human readable format
	* and noting the file was created by this class and not a human.  This might help future proofing human error.
	* @access	private
	* @param	void
	* @return	string	Returns a dockblock comment that will go in a head section of a cache file.
	*/
	private function getCacheDocBlock(){
		$tmStmp	 = date('F d, Y - H:i:s T');
		$expires	= date('F d, Y - H:i:s T', mktime(date('H'), date('i'), date('s'), date('m'), date('d')+1, date('Y')));
		$comment	 = "\n/** \n* Cache file created by cacheMgr class \n* \n* You should not edit this file unless you know what you are doing. \n* If you do edit the file and the ads system crashes, just delete \n* this file.  It will be re-built.\n* @version	$tmStmp \n* @expires	$expires \n* @author	CAMS::cacheMgr \n*/";
		return $comment;
	}
	
	/**
	* This method creates a cache file 
	*
	* Takes incoming string data and writes it out to a file.  If class var $secure is true ads a constant 
	* check to the top of the class.
	* @access	 private
	* @uses		cache::cachePath Used to define the path to the cache directory
	* @uses		DS				A Constant for DIRECTORY_SEPERATOR
	* @param	string	$fileName	A md5 or sha1 generated hash and file extension file name.
	* @param	string	$outString	The data that is to be writen out to a file.
	* @return	boolean	On sucess return true.  On fail return false.
	*/
	private function setCacheFile($uniquieId, $outString){
		$uniquieId = str_replace(' ', '_', $uniquieId);
		$fileName	 = $this->getHash($uniquieId) . '.' . $this->fileExt;
		$outString	 = $this->prepStrForOut($outString);
		$cacheFile	= $this->cachePath . $fileName;
		if(file_put_contents($cacheFile, $outString) === false){
			return false;
		}
		return $fileName;
	}
	
	/**
	* This method preps a string that will be cached out with header and footer charaters it will need
	*
	* If the request is to create a secured cache file, a check for a joomla defined constant will be added to 
	* the header.
	* @access	private
	* @param	string	$outString	The string that will be written out to a file
	* @return	string	A new string with header and footer data will be returned.
	*/
	private function prepStrForOut($outString){
		if($this->secure){
		$outHeader	 = "<"."?php ".$this->getCacheDocBlock()." \ndefined( '_VALID_AMS_' ) or die( 'Restricted access' ); \n";
		}else{
			$outHeader	 = "<?php 
						".$this->getCacheDocBlock()." \n";
		}
		$outFooter	 = " \n?".">";
		$outString	= $outHeader . $outString . $outFooter;
		return $outString;
	}
}
?>


_________________________
My New site OpenEyes