Yes..

<?php

        $m1 = new MemCached('Pool');
        $m1->addServer('127.0.0.1', 11211);

        $m2 = new MemCached('Pool');
        $m2->addServer('127.0.0.1', 11211);

        var_dump($m2->getServerList());
?>

Will output

array(2) {
  [0]=>
  array(3) {
    ["host"]=>
    string(9) "127.0.0.1"
    ["port"]=>
    int(11211)
    ["weight"]=>
    int(0)
  }
  [1]=>
  array(3) {
    ["host"]=>
    string(9) "127.0.0.1"
    ["port"]=>
    int(11211)
    ["weight"]=>
    int(0)
  }
}

Which is probably not what is intended.


Wrapping the 2nd call to addServer...

if ($m2->isPristine())
{
        $m2->addServer('127.0.0.1', 11211);
}

Will output

array(1) {
  [0]=>
  array(3) {
    ["host"]=>
    string(9) "127.0.0.1"
    ["port"]=>
    int(11211)
    ["weight"]=>
    int(0)
  }
}

Jared


On Apr 6, 10:37 pm, Jay Paroline <[email protected]> wrote:
> The singleton isn't shared across processes though.
> We also use a singleton, but the constructor still gets called once
> for each process that gets fired up.
>
> If we are using connection pooling, do we need to worry about multiple
> PHP processes adding servers?
>
> Jay
>
> On Apr 6, 5:06 pm, Brian Moon <[email protected]> wrote:
>
>
>
> > >> Just give a string parameter to the memcached constructor , any class
> > >> instance with the same string as parameter should use the same
> > >> connection.
>
> > >> /tyn
>
> > > Yeah, only thing to watch out for is not to add the servers more than
> > > once.
>
> > We use a singleton to avoid this. We pass in the "config" we want. it is
> > loaded and the singleton created.
>
> > Brian.


-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to