On 02/03/2011 10:49 PM, Adam Richardson wrote:
On Thu, Feb 3, 2011 at 4:19 PM, Jostein Eriksen<php-list@xxxxxxxxxx> 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php