Issues

ZF-7215: Zend_Cache_Frontend_Function::call() returns NULL under high load

Issue Type: Bug Created: 2009-07-07T05:23:05.000+0000 Last Updated: 2010-03-01T10:09:19.000+0000 Status: Closed Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: oscar (oscar) Assignee: Marc Bennewitz (private) (mabe) Tags: - Zend_Cache

Related issues: Attachments:

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().

<pre class="highlight">
     /**
     * 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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts