lithium\storage\cache\adapter\Memcache::increment PHP Method

increment() public method

Note that, as per the Memcached specification: "If the item's value is not numeric, it is treated as if the value were 0."
public increment ( string $key, integer $offset = 1 ) : integer | boolean
$key string Key of numeric cache item to increment.
$offset integer Offset to increment - defaults to `1`.
return integer | boolean The item's new value on successful increment, else `false`.
    public function increment($key, $offset = 1)
    {
        return $this->connection->increment($key, $offset);
    }

Usage Example

Beispiel #1
0
 public function testIncrementWithScope()
 {
     $adapter = new Memcache(array('scope' => 'primary'));
     $this->_conn->set('primary:key1', 1, 60);
     $this->_conn->set('key1', 1, 60);
     $adapter->increment('key1');
     $expected = 1;
     $result = $this->_conn->get('key1');
     $this->assertEqual($expected, $result);
     $expected = 2;
     $result = $this->_conn->get('primary:key1');
     $this->assertEqual($expected, $result);
 }