I am curious is there a possibility in PHP to copy key/value from one memcached server directly to another using Memcached module? Is connections to 2 different servers at one time allowed at all?
Thanks in advance!
I am curious is there a possibility in PHP to copy key/value from one memcached server directly to another using Memcached module? Is connections to 2 different servers at one time allowed at all?
Thanks in advance!
The following would allow you to connect to two different Memcached servers and set the same data on both:
//Server A
$memcacheA = new Memcache;
$memcacheA->connect(216.239.51.99, 11211) or die ("Could not connect");
//Server B
$memcacheB = new Memcache;
$memcacheB->connect(115.239.51.98, 11211) or die ("Could not connect");
//Getting data from your database.
$myVal = $customObj->getSomethingFromDB();
//If data not stored on Server A
if($memcacheA->get('var_key') === false){
//Store it on Server A
$memcacheA->set('var_key', $myVar, MEMCACHE_COMPRESSED, 50);
}
//If data not stored on Server B
if($memcacheB->get('var_key') === false){
//Store it on Server B
$memcacheB->set('var_key', $myVar, MEMCACHE_COMPRESSED, 50);
}
Depending on your use case, this may or may not be a good solution. Depends on what your situation is and what you're attempting to achieve.