예제 #1
0
 public function testGetMany()
 {
     $memcache = new Memcache();
     $request = new MemcacheGetRequest();
     $request->addKey("key1");
     $request->addKey("key2");
     $request->addKey("key3");
     $response = new MemcacheGetResponse();
     $item3 = $response->addItem();
     $item3->setKey("key3");
     $item3->setValue("value3");
     $item3->setFlags(0);
     // string.
     $item1 = $response->addItem();
     $item1->setKey("key1");
     $item1->setValue("value1");
     $item1->setFlags(0);
     // string.
     $this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
     $this->assertEquals(array("key1" => "value1", "key3" => "value3"), memcache_get($memcache, array("key1", "key2", "key3")));
     $this->apiProxyMock->verify();
 }
예제 #2
0
 public function testTouchSuccess()
 {
     $request = new MemcacheGetRequest();
     $request->addKey("key");
     $request->setForCas(true);
     $response = new MemcacheGetResponse();
     $item = $response->addItem();
     $item->setKey("key");
     $item->setValue("value");
     $item->setFlags(0);
     // string.
     $item->setCasId(123456);
     $this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
     $request = new MemcacheSetRequest();
     $item = $request->addItem();
     $item->setKey("key");
     $item->setValue("value");
     $item->setFlags(0);
     // string
     $item->setCasId(123456);
     $item->setSetPolicy(SetPolicy::CAS);
     $item->setExpirationTime(999);
     $response = new MemcacheSetResponse();
     $response->addSetStatus(SetStatusCode::STORED);
     $this->apiProxyMock->expectCall('memcache', 'Set', $request, $response);
     $memcached = new Memcached();
     $this->assertTrue($memcached->touch("key", 999));
     $this->apiProxyMock->verify();
 }