|
ObjectbaseClass
class.objectbase.php - a php class for the simple object caching
DESCRIPTION I hate documenting my code. I cannot lie. But its pretty easy. I will make more documentation later. Basically you just do this: EXAMPLE <?
include 'class.objectbase.php';
$objectBase = new objectBase(); // instantiate the class
$datadir = './data'; // set the cache dir
$datahash = 'example'; // set the md5 hash
$cachetime = 360; // the cache time
$objectBase->config($datadir, $datahash); // config the class (not required)
if ($objectBase->getAge('example')>$cachetime) //check if object is cached and if so how long ago
{
$exampleResults = doSomeStuffTHatNeedsCacheing($stuff); // get stuff/object
$objectBase->setObject('example',$exampleResults); // store object
}
$exampleResults = $objectBase->getObject('example'); // get object
?>This will successfully cache the $exampleResults object - no matter what the results. It will be in a hashed dir in the data dir. There should be no collisions with other cached data, however MD5s can collide.
|
Sign in to add a comment