Multiple memcached servers question.

Posted by Andre on Stack Overflow See other posts from Stack Overflow or by Andre
Published on 2011-01-17T20:30:51Z Indexed on 2011/01/17 20:53 UTC
Read the original article Hit count: 224

Filed under:
|

hypothetically - if I have multiple memcached servers like this:

//PHP 
$MEMCACHE_SERVERS = array(
    "10.1.1.1", //web1
    "10.1.1.2", //web2
    "10.1.1.3", //web3 
); 
$memcache = new Memcache();
foreach($MEMCACHE_SERVERS as $server){
    $memcache->addServer ( $server ); 
}

And then I set data like this:

$huge_data_for_frong_page = 'some data blah blah blah';
$memcache->set("huge_data_for_frong_page", $huge_data_for_frong_page);

And then I retrieve data like this:

$huge_data_for_frong_page = $memcache->get("huge_data_for_frong_page");

When i would to retrieve this data from memcached servers - how would php memcached client know which server to query for this data? Or is memcached client going to query all memcached servers?

© Stack Overflow or respective owner

Related posts about php

Related posts about memcached