diff --git a/src/Illuminate/Cache/RedisTaggedCache.php b/src/Illuminate/Cache/RedisTaggedCache.php index d2325a007afd..c83ee42f083b 100644 --- a/src/Illuminate/Cache/RedisTaggedCache.php +++ b/src/Illuminate/Cache/RedisTaggedCache.php @@ -32,6 +32,34 @@ public function put($key, $value, $minutes = null) parent::put($key, $value, $minutes); } + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + $this->pushStandardKeys($this->tags->getNamespace(), $key); + + parent::increment($key, $value); + } + + /** + * Decrement the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + $this->pushStandardKeys($s->tags->getNamespace(), $key); + + parent::decrement($key, $value); + } + /** * Store an item in the cache indefinitely. * diff --git a/src/Illuminate/Cache/TaggedCache.php b/src/Illuminate/Cache/TaggedCache.php index 095f296af613..c37025d7c2de 100644 --- a/src/Illuminate/Cache/TaggedCache.php +++ b/src/Illuminate/Cache/TaggedCache.php @@ -42,7 +42,7 @@ public function increment($key, $value = 1) } /** - * Increment the value of an item in the cache. + * Decrement the value of an item in the cache. * * @param string $key * @param mixed $value diff --git a/tests/Cache/CacheTaggedCacheTest.php b/tests/Cache/CacheTaggedCacheTest.php index 2f6d20552df7..c38543a68979 100644 --- a/tests/Cache/CacheTaggedCacheTest.php +++ b/tests/Cache/CacheTaggedCacheTest.php @@ -52,6 +52,24 @@ public function testTagsWithStringArgument() $this->assertEquals('bar', $store->tags('bop')->get('foo')); } + public function testTagsWithIncrementCanBeFlushed() + { + $store = new ArrayStore; + $store->tags('bop')->increment('foo', 5); + $this->assertEquals(5, $store->tags('bop')->get('foo')); + $store->tags('bop')->flush(); + $this->assertNull($store->tags('bop')->get('foo')); + } + + public function testTagsWithDecrementCanBeFlushed() + { + $store = new ArrayStore; + $store->tags('bop')->decrement('foo', 5); + $this->assertEquals(-5, $store->tags('bop')->get('foo')); + $store->tags('bop')->flush(); + $this->assertNull($store->tags('bop')->get('foo')); + } + public function testTagsCacheForever() { $store = new ArrayStore;