private function clear() { foreach (array(11211, 11212, 11221) as $port) { $cmr = new Cm([['host' => '127.0.0.1', 'port' => $port]]); $cmr->remove('b'); $cmr->remove('c'); $cmr->remove('d'); } }
public function testReplicationAndSharding() { $replica0 = ['host' => '127.0.0.1', 'port' => 11211]; $replica1 = ['host' => '127.0.0.1', 'port' => 11212]; $shardA = [$replica0, $replica1]; $shardB = ['host' => '127.0.0.1', 'port' => 11221]; $scm = new Cm([$shardA, $shardB]); $scm->remove("a"); $scm->remove("b"); $this->assertTrue($scm->set("a", "valueA"), "set success a"); $this->assertTrue($scm->set("b", "valueB"), "set success b"); $scmA = new Cm([$shardA]); $this->assertEquals($scmA->get("b"), "valueB", "eq-1"); $scmB = new Cm([$shardB]); $this->assertEquals($scmB->get("a"), "valueA", "eq-2"); }