Re: Memcache problems

From: Date: Thu, 03 Feb 2011 22:00:12 +0000
Subject: Re: Memcache problems
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-311138@lists.php.net to get a copy of this message
On 02/03/2011 10:49 PM, Adam Richardson wrote:
On Thu, Feb 3, 2011 at 4:19 PM, Jostein Eriksen<php-list@morits.net> wrote:
Both php and memcached is running on the same server. memcached version 1.2.2 php5-memcache version 2.2.0 php version 5.2.4 here is a snippet from my code that may be of interest $cfg['serverList'] = array('127.0.0.1', 11211, 1, 1); ... $this->memcache = new Memcache(); foreach($cfg['serverList'] as $value){
                                /** host, port, persistent, weight, timeout,
retry interval, status, failure callback */
                                $this->memcache->addServer($value[0],
$value[1], false, $value[2], $value[3], 2, true, array($this, 'fail'));
                        }
Are you sure you copied this correctly? In the code above, you set the array key 'serverList' to an array containing ('127.0.0.1', 11211, 1, 1); Then, you foreach through the values of the 'serverList' array (first iteration, value would equal '127.0.0.1', second, value would equal 11211, etc.) Then, you use array notation to access the first position of $value. In the first iteration of the foreach, $value would equal '127.0.0.1', so $value[0] would give you '1', $value[1] would give you '2', etc. Do you see what I'm saying? Did you forget or omit other relevant code? Or, I'm just having a really bad code day (in this case, I'll likely see my error just after sending this email.) Adam
My bad. it should be: 'serverList' => array( /** host, port, weight, timeout */ 'default' => array('127.0.0.1', 11211, 1, 1), )), Didn't copy/paste the $cfg = line, so it got messed up. /Jostein

« previous php.general (#311138) next »