public function testNonExistantKey() { $backend = new MongoCounter(array('127.0.0.1:27017'), 'sonata_counter_test', 'counter'); $counter = $backend->increment(Counter::create('mynewcounter.inc', 10)); $this->assertEquals(11, $counter->getValue()); $counter = $backend->decrement(Counter::create('mynewcounter.dec', 10)); $this->assertEquals(9, $counter->getValue()); }
public function testNonExistantKey() { $backend = new MemcachedCounter('prefix', array(array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100))); $counter = $backend->increment(Counter::create('mynewcounter.inc', 10)); $this->assertEquals(11, $counter->getValue()); $counter = $backend->decrement(Counter::create('mynewcounter.dec', 10)); $this->assertEquals(9, $counter->getValue()); }
public function testNonExistantKey() { $backend = new PRedisCounter($this->parameters); $counter = $backend->increment(Counter::create('mynewcounter.inc', 10)); $this->assertEquals(11, $counter->getValue()); $counter = $backend->decrement(Counter::create('mynewcounter.dec', 10)); $this->assertEquals(9, $counter->getValue()); }
/** * @param mixed $value * @param Counter $counter * @param int $number * * @return Counter */ protected function handleDecrement($value, Counter $counter, $number) { if ($value === false) { $counter = $this->set(Counter::create($counter->getName(), $counter->getValue() + -1 * $number)); } else { $counter = Counter::create($counter->getName(), $value); } return $counter; }
/** * {@inheritdoc} */ public function get($name) { return Counter::create($name, (int) apc_fetch($this->prefix . '/' . $name)); }
/** * {@inheritdoc} */ public function get($name) { return Counter::create($name, (int) $this->getClient()->get($name)); }
/** * {@inheritdoc} */ public function get($name) { return Counter::create($name, (int) $this->getCollection()->get($this->prefix . '.' . $name)); }
/** * {@inheritdoc} */ public function get($name) { $result = $this->getCollection()->findOne(array('counter' => $name)); return Counter::create($name, $result ? (int) $result['value'] : 0); }
public function testNonExistantKey() { $backend = new ApcCounter('prefix'); $counter = $backend->increment(Counter::create('mycounter', 10)); $this->assertEquals(11, $counter->getValue()); }
public function testClass() { $counter = Counter::create('mycounter', 42); $this->assertEquals('mycounter', $counter->getName()); $this->assertEquals(42, $counter->getValue()); }