Cachearium\CacheAbstract::increment PHP Method

increment() abstract public method

Backend must only guarantee that the increment is made, but the final value may not be current + $value due to concurrent accesses.
abstract public increment ( integer $value, CacheKey $k, integer $default ) : integer
$value integer
$k CacheKey
$default integer If key is not in cache, this value is returned.
return integer
    public abstract function increment($value, CacheKey $k, $default = 0);

Usage Example

 public function increment(CacheAbstract $cache)
 {
     $key = new CacheKey('increment', 'it');
     $cache->delete($key);
     $this->assertEquals(5, $cache->increment(1, $key, 5));
     $this->assertEquals(6, $cache->increment(1, $key, 5));
 }