I found PEAR's Cache_Lite and was really interested in testing it out. However, I'm having a problem where it seems to create the cache with the wrong information and doesn't see it as being cached at all. For example, I'm using the following code:
// Include the package
require_once('Cache/Lite.php');
// set an ID for this cache
$id = "ct1289";
// Set a few options
$options = array('cacheDir' => 'cache/',
'lifeTime' => 3600
);
// Create a Cache_Lite object
$objCache = new Cache_Lite($options);
// Test if thereis a valide cache for this id
if ($quote = $objCache->get($id)) {
echo $quote;
echo " [cached]";
} else { // No valid cache found
$quote = "Test";
echo $quote;
$objCache->save($data);
}
I can refresh the page endlessly but it continually prints "Test" to the screen but not "[cached]". I checked my cache directory and it did in fact create a cache file. However, the file is blank. I was wondering how I can fix this. I wasn't sure if the cache file was supposed to have anything in it. Also, like I said, it doesn't find the cache. Thanks in advance for any help you can offer.