示例#1
0
 public function testSetSuccessCompressed()
 {
     $memcache = new Memcache();
     $request = new MemcacheSetRequest();
     $item = $request->addItem();
     $item->setKey("float");
     $item->setValue("3");
     $item->setFlags(6);
     // float
     $item->setSetPolicy(SetPolicy::SET);
     $item->setExpirationTime(30);
     $response = new MemcacheSetResponse();
     $response->addSetStatus(SetStatusCode::STORED);
     $this->apiProxyMock->expectCall('memcache', 'Set', $request, $response);
     $this->assertTrue(memcache_set($memcache, "float", 3.0, MEMCACHE_COMPRESSED, 30));
     $this->apiProxyMock->verify();
 }
 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();
 }