/** * Increment the number stored at key by one. * * @param string $key * * @return int the new value * @link http://redis.io/commands/incr * @example * <pre> * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1 * $redis->incr('key1'); // 2 * $redis->incr('key1'); // 3 * $redis->incr('key1'); // 4 * </pre> */ public function incr($key) { try { return $this->client->incr($key); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }
public function testBatchCommandsAreNotSentTwice() { $this->redis->del('testBatchCommand'); $this->assertTrue($this->redis->stream()); $this->assertTrue($this->redis->incr('testBatchCommand')); $this->assertSame([], $this->redis->exec()); $this->assertEquals(1, $this->redis->get('testBatchCommand')); $this->assertEquals(2, $this->redis->incr('testBatchCommand')); $this->assertTrue($this->redis->stream()); $this->assertTrue($this->redis->incr('testBatchCommand')); $this->assertSame([], $this->redis->exec()); $this->assertEquals(3, $this->redis->get('testBatchCommand')); }
/** * {@inheritdoc} */ public function incr($key) { unset($this->cache[$key]); return $this->redis->incr($key); }