decrement() public method

Note that if the value of the specified key is *not* an integer, the decrement operation will have no effect whatsoever. Redis chooses to not typecast values to integers when performing an atomic decrement operation.
public decrement ( string $key, integer $offset = 1 ) : integer | boolean
$key string Key of numeric cache item to decrement.
$offset integer Offset to decrement - defaults to `1`.
return integer | boolean The item's new value on successful decrement, else `false`.
Esempio n. 1
0
 public function testDecrementWithScope()
 {
     $adapter = new Redis(array('scope' => 'primary'));
     $this->_redis->set('primary:key1', 1, 60);
     $this->_redis->set('key1', 1, 60);
     $adapter->decrement('key1');
     $expected = 1;
     $result = $this->_redis->get('key1');
     $this->assertEqual($expected, $result);
     $expected = 0;
     $result = $this->_redis->get('primary:key1');
     $this->assertEqual($expected, $result);
 }