-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated tests * Updated FixedTaggingCachePool * Using new collector * Fixes * Updating to nicer profiler page * Minor * cs * Make sure we support sf < 3.3 * minor * Bugfix and more tests * Namespace update * Remove support for PHP 5.5 * Minor * Added change log * Do not require old phpunit versions
- Loading branch information
Showing
20 changed files
with
448 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,21 +11,20 @@ | |
|
||
namespace Cache\CacheBundle\Cache; | ||
|
||
use Cache\Taggable\TaggableItemInterface; | ||
use Cache\Taggable\TaggablePoolInterface; | ||
use Cache\TagInterop\TaggableCacheItemInterface; | ||
use Cache\TagInterop\TaggableCacheItemPoolInterface; | ||
use Psr\Cache\CacheItemInterface; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
use Psr\Cache\InvalidArgumentException; | ||
|
||
/** | ||
* This class is a decorator for a TaggablePoolInterface. It tags everything with predefined tags. | ||
* Use this class with the DoctrineBridge. | ||
* This class is a decorator for a TaggableCacheItemPoolInterface. It tags everything with predefined tags. | ||
* | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
class FixedTaggingCachePool implements CacheItemPoolInterface | ||
class FixedTaggingCachePool implements TaggableCacheItemPoolInterface | ||
{ | ||
/** | ||
* @type CacheItemPoolInterface|TaggablePoolInterface | ||
* @type TaggableCacheItemPoolInterface | ||
*/ | ||
private $cache; | ||
|
||
|
@@ -35,10 +34,10 @@ class FixedTaggingCachePool implements CacheItemPoolInterface | |
private $tags; | ||
|
||
/** | ||
* @param TaggablePoolInterface $cache | ||
* @param array $tags | ||
* @param TaggableCacheItemPoolInterface $cache | ||
* @param array $tags | ||
*/ | ||
public function __construct(TaggablePoolInterface $cache, array $tags) | ||
public function __construct(TaggableCacheItemPoolInterface $cache, array $tags) | ||
{ | ||
$this->cache = $cache; | ||
$this->tags = $tags; | ||
|
@@ -97,10 +96,12 @@ public function deleteItems(array $keys) | |
*/ | ||
public function save(CacheItemInterface $item) | ||
{ | ||
if ($item instanceof TaggableItemInterface) { | ||
$this->addTags($item); | ||
if (!$item instanceof TaggableCacheItemInterface) { | ||
throw new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement TaggableCacheItemInterface.'); | ||
} | ||
|
||
$item->setTags($this->tags); | ||
|
||
return $this->cache->save($item); | ||
} | ||
|
||
|
@@ -109,26 +110,36 @@ public function save(CacheItemInterface $item) | |
*/ | ||
public function saveDeferred(CacheItemInterface $item) | ||
{ | ||
$this->addTags($item); | ||
if (!$item instanceof TaggableCacheItemInterface) { | ||
throw new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement TaggableCacheItemInterface.'); | ||
} | ||
|
||
$item->setTags($this->tags); | ||
|
||
return $this->cache->saveDeferred($item); | ||
} | ||
|
||
/** | ||
* @param TaggableItemInterface $item | ||
* {@inheritdoc} | ||
*/ | ||
private function addTags(TaggableItemInterface $item) | ||
public function commit() | ||
{ | ||
foreach ($this->tags as $tag) { | ||
$item->addTag($tag); | ||
} | ||
return $this->cache->commit(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function commit() | ||
public function invalidateTag($tag) | ||
{ | ||
return $this->cache->commit(); | ||
return $this->invalidateTag($tag); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function invalidateTags(array $tags) | ||
{ | ||
return $this->cache - $this->invalidateTags($tags); | ||
} | ||
} |
Oops, something went wrong.