Re: Memcache problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux