ZF-7215: Zend_Cache_Frontend_Function::call() returns NULL under high load
Description
Sometimes under high load the call to Zend_Cache_Frontend_Function::call() returns NULL.
Looking at the source code below seems that it is possible if the cache expires between the calls $this->test() and $this->load().
/**
* Main method : call the specified function or get the result from cache
*
* @param string $name Function name
* @param array $parameters Function parameters
* @param array $tags Cache tags
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
* @return mixed Result
*/
public function call($name, $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)
{
$cacheBool1 = $this->_specificOptions['cache_by_default'];
$cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']);
$cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']);
$cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
if (!$cache) {
// We do not have not cache
return call_user_func_array($name, $parameters);
}
$id = $this->_makeId($name, $parameters);
if ($this->test($id)) {
// A cache is available
$result = $this->load($id);
$output = $result[0];
$return = $result[1];
} else {
// A cache is not available
ob_start();
ob_implicit_flush(false);
$return = call_user_func_array($name, $parameters);
$output = ob_get_contents();
ob_end_clean();
$data = array($output, $return);
$this->save($data, $id, $tags, $specificLifetime, $priority);
}
echo $output;
return $return;
}
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2009-07-07T05:57:45.000+0000
Assigning to Alex
Posted by Marc Bennewitz (private) (mabe) on 2010-03-01T10:09:18.000+0000
duplicates ZF-5514