Skip to content

Updated tests and collector #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ php:
- 7.1
- 7.0
- 5.6
- 5.5
- hhvm

env:
Expand All @@ -16,6 +15,7 @@ env:
matrix:
- SYMFONY_VERSION=2.7.*
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.1.*
- SYMFONY_VERSION=3.2.*

branches:
Expand All @@ -26,7 +26,7 @@ branches:
matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
env: COMPOSER_COMMAND="composer update --prefer-lowest --prefer-stable" COVERAGE=true TEST_COMMAND="php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-clover=coverage.xml" SYMFONY_VERSION=2.7.*

cache:
Expand All @@ -36,7 +36,6 @@ cache:
before_install:
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi;
- pip install --user codecov
- composer self-update
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update

install:
Expand Down
13 changes: 13 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee

## UNRELEASED

## 0.5.0

### Changed

- Using cache/session-handler: ^0.2. **This will break all cached sessions**
- Using cache/taggable-cache: ^0.5 to support the latest versions of the adapters.

## 0.4.4

### Fixed

- Make sure RecordingPool does not change the type of pool.

## 0.4.3

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
}
],
"require": {
"php": "^5.5 || ^7.0",
"php": "^5.6 || ^7.0",
"symfony/framework-bundle": "^2.7 || ^3.0",
"cache/taggable-cache": "^0.5",
"cache/session-handler": "^0.2"
},
"require-dev": {
"phpunit/phpunit": "^5.1 || ^4.0",
"phpunit/phpunit": "^5.7.17",
"symfony/symfony": "^2.7 || ^3.0",
"cache/psr-6-doctrine-bridge": "^2.0",
"cache/psr-6-doctrine-bridge": "^3.0",
"cache/array-adapter": "^0.5",
"nyholm/symfony-bundle-test": "^1.0.1",
"matthiasnoback/symfony-dependency-injection-test": "^1.0"
Expand Down
51 changes: 31 additions & 20 deletions src/Cache/FixedTaggingCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tobias.nyholm@gmail.com>
*/
class FixedTaggingCachePool implements CacheItemPoolInterface
class FixedTaggingCachePool implements TaggableCacheItemPoolInterface
{
/**
* @type CacheItemPoolInterface|TaggablePoolInterface
* @type TaggableCacheItemPoolInterface
*/
private $cache;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}
}
Loading