<?php
/**
* ReallySimpleContentCache - demo file for not so simple useage
* As the name suggests, this is class is for really simple content caching
*
* Copyright 2007 Rob Searles
* http://www.ibrow.com
* Please give me credit if you use this. Thanks
*
* History:
* I originally built this for caching XML which had been constructed
* out of database calls. I had a Flash front end talking to PHP in the
* backend, the PHP would then go and interrogate the database, construct
* some more XML which it would return. There were many calls being made to
* the database, so I decided to cache the final reply XML.
*
* It's not bullet proof, and doesn't have a great deal of functionality,
* but it is a quick and dirty solution to a little scratch I had to itch
* Play around with it, learn, improve and enjoy. I hope you find it useful
*
* copyright 2007 rob searles
* Licenced under the GNU Lesser General Public License (Version 3)
* http://www.gnu.org/licenses/lgpl.html
*/
require('ReallySimpleContentCache.php');
/**
* Initiate ReallySimpleContentCache class
*/
$Cache = new ReallySimpleContentCache();
/**
* Set the ID of this cache file
*/
$Cache->set_id('test2');
/**
* Set timeout limit to 0.1 of an hour - er, 6 minutes?
*/
$Cache->set_limit(0.1);
/**
* Try to get any content from the Cache
*/
$content = $Cache->get();
/**
* If no content has been given, go off and create some
*/
if(!$content) {
$content = '<html><body><h1>Hello</h1><p>This <em>hard</em> file was
created on '.date ('F d Y H:i:s.', time()).'</p></body></html>';
/**
* now cache this content
*/
$Cache->save($content);
}
/**
* output the content
*/
echo $content;
?>
|