コード例 #1
0
 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());
 }
コード例 #2
0
 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());
 }
コード例 #3
0
 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());
 }
コード例 #4
0
ファイル: BaseCounter.php プロジェクト: sonata-project/cache
 /**
  * @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;
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     return Counter::create($name, (int) apc_fetch($this->prefix . '/' . $name));
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     return Counter::create($name, (int) $this->getClient()->get($name));
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     return Counter::create($name, (int) $this->getCollection()->get($this->prefix . '.' . $name));
 }
コード例 #8
0
ファイル: MongoCounter.php プロジェクト: sonata-project/cache
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     $result = $this->getCollection()->findOne(array('counter' => $name));
     return Counter::create($name, $result ? (int) $result['value'] : 0);
 }
コード例 #9
0
 public function testNonExistantKey()
 {
     $backend = new ApcCounter('prefix');
     $counter = $backend->increment(Counter::create('mycounter', 10));
     $this->assertEquals(11, $counter->getValue());
 }
コード例 #10
0
ファイル: CounterTest.php プロジェクト: LamaDelRay/test_symf
 public function testClass()
 {
     $counter = Counter::create('mycounter', 42);
     $this->assertEquals('mycounter', $counter->getName());
     $this->assertEquals(42, $counter->getValue());
 }