Example #1
0
 /**
  * Locks the cache for a given Request.
  *
  * @param Request $request A Request instance
  *
  * @return Boolean|string true if the lock is acquired, the path to the current lock otherwise
  */
 public function lock(Request $request)
 {
     $metadataKey = $this->getMetadataKey($request);
     $this->client->createConnection();
     $result = $this->client->hSetNx($this->lock_key, $metadataKey, 1);
     $this->client->close();
     return $result == 1;
 }
Example #2
0
 public function testHashGet()
 {
     $client = new Client(array('host' => 'localhost'));
     $connection = $client->createConnection();
     $this->assertTrue($connection);
     $client->hSetNx('testkey', 'testhash', 1);
     $result = $client->hGet('testkey', 'testhash');
     $this->assertEquals(1, $result);
     $client->del('testkey');
 }