Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function increment($counter, $value = 1)
 {
     $counter = $this->transformCounter($counter);
     $counter = new Counter($counter->getName(), $counter->getValue() + $value);
     $this->setCounter($counter);
     return $counter;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function setCounter(Counter $counter)
 {
     $file = $this->getCacheKey($counter->getName());
     $this->filesystem->mkdir(dirname($file));
     file_put_contents($file, $counter->getValue());
     return $counter;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function setCounter(Counter $counter)
 {
     $key = $this->getCacheKey($counter->getName());
     apc_store($key, $counter->getValue());
     return $counter;
 }
Esempio n. 4
0
 public function testCounter()
 {
     $counter = new Counter('foo', 42);
     $this->assertEquals('foo', $counter->getName());
     $this->assertEquals(42, $counter->getValue());
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function setCounter(Counter $counter)
 {
     $cmd = $this->client->createCommand('set', array($counter->getName(), $counter->getValue()));
     $this->client->executeCommand($cmd);
     return $counter;
 }