Serializing error when using retrieve($key, true)
smcjones opened this issue · comments
Thanks for this wonderful and simple caching library. It's exactly what I need!
Just FYI, this notice occurs on line 105 of cache.class.php in my version
of PHP, 5.6.14.
The fix is to only serialize when $type == 'data'. My quick fix was this:
/**
* Retrieve cached data by its key
*
* @param string $key
* @param boolean [optional] $timestamp
* @return string
*/
public function retrieve($key, $timestamp = false) {
$cachedData = $this->_loadCache();
(false === $timestamp) ? $type = 'data' : $type = 'time';
if (!isset($cachedData[$key][$type])) return null;
if ($type == 'time') {
return $cachedData[$key][$type];
}
return unserialize($cachedData[$key][$type]);
}
saved me some time, still using this script ^^