From 78193a64e2a6541f5c1b1c47d8082549bb729ea1 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 14:47:16 +0200 Subject: [PATCH 01/15] Updated tests --- src/Cache/FixedTaggingCachePool.php | 35 ++++++---- tests/Functional/BaseTestCase.php | 33 ---------- tests/Functional/BundleInitializationTest.php | 27 +++++++- tests/Functional/app/AppKernel.php | 66 ------------------- tests/Functional/app/config/default.yml | 2 - tests/Functional/app/config/framework.yml | 11 ---- tests/Functional/app/config/routing.yml | 0 tests/Functional/config.yml | 38 +++++++++++ 8 files changed, 84 insertions(+), 128 deletions(-) delete mode 100644 tests/Functional/BaseTestCase.php delete mode 100644 tests/Functional/app/AppKernel.php delete mode 100644 tests/Functional/app/config/default.yml delete mode 100644 tests/Functional/app/config/framework.yml delete mode 100644 tests/Functional/app/config/routing.yml create mode 100644 tests/Functional/config.yml diff --git a/src/Cache/FixedTaggingCachePool.php b/src/Cache/FixedTaggingCachePool.php index 4ac11c9..6ed4e26 100644 --- a/src/Cache/FixedTaggingCachePool.php +++ b/src/Cache/FixedTaggingCachePool.php @@ -13,8 +13,11 @@ 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. @@ -22,10 +25,10 @@ * * @author Tobias Nyholm */ -class FixedTaggingCachePool implements CacheItemPoolInterface +class FixedTaggingCachePool implements TaggableCacheItemPoolInterface { /** - * @type CacheItemPoolInterface|TaggablePoolInterface + * @type TaggableCacheItemPoolInterface */ private $cache; @@ -35,10 +38,10 @@ class FixedTaggingCachePool implements CacheItemPoolInterface private $tags; /** - * @param TaggablePoolInterface $cache + * @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; @@ -95,7 +98,7 @@ public function deleteItems(array $keys) /** * {@inheritdoc} */ - public function save(CacheItemInterface $item) + public function save(TaggableCacheItemInterface $item) { if ($item instanceof TaggableItemInterface) { $this->addTags($item); @@ -107,7 +110,7 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} */ - public function saveDeferred(CacheItemInterface $item) + public function saveDeferred(CacheItemPoolInterface $item) { $this->addTags($item); @@ -115,20 +118,26 @@ public function saveDeferred(CacheItemInterface $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); } } diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/BaseTestCase.php deleted file mode 100644 index bb5a121..0000000 --- a/tests/Functional/BaseTestCase.php +++ /dev/null @@ -1,33 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\CacheBundle\Tests\Functional; - -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - -class BaseTestCase extends WebTestCase -{ - protected static function getKernelClass() - { - require_once __DIR__.'/app/AppKernel.php'; - - return 'Cache\CacheBundle\Tests\Functional\app\AppKernel'; - } - - protected static function createKernel(array $options = []) - { - $class = self::getKernelClass(); - - return new $class( - isset($options['config']) ? $options['config'] : 'default.yml' - ); - } -} diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php index 38006e2..15eb7e6 100644 --- a/tests/Functional/BundleInitializationTest.php +++ b/tests/Functional/BundleInitializationTest.php @@ -11,10 +11,31 @@ namespace Cache\CacheBundle\Tests\Functional; -class BundleInitializationTest extends BaseTestCase +use Cache\CacheBundle\CacheBundle; +use Nyholm\BundleTest\BaseBundleTestCase; + +/** + * @author Tobias Nyholm + */ +class BundleInitializationTest extends BaseBundleTestCase { - public function testRegisterBundle() + protected function getBundleClass() + { + return CacheBundle::class; + } + + protected function setUp() { - static::createClient(); + parent::setUp(); + $kernel = $this->createKernel(); + $kernel->addConfigFile(__DIR__.'/config.yml'); + } + + public function testInitBundle() + { + $this->bootKernel(); + $container = $this->getContainer(); + + $this->assertTrue($container->hasParameter('cache.provider_service_ids')); } } diff --git a/tests/Functional/app/AppKernel.php b/tests/Functional/app/AppKernel.php deleted file mode 100644 index 6b76758..0000000 --- a/tests/Functional/app/AppKernel.php +++ /dev/null @@ -1,66 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\CacheBundle\Tests\Functional\app; - -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\Kernel; - -class AppKernel extends Kernel -{ - private $config; - - public function __construct($config) - { - parent::__construct('test', true); - - $fs = new Filesystem(); - - if (!$fs->isAbsolutePath($config)) { - $config = __DIR__.'/config/'.$config; - } - - if (!file_exists($config)) { - throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config)); - } - - $this->config = $config; - } - - public function registerBundles() - { - return [ - new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), - new \Cache\CacheBundle\CacheBundle(), - ]; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - $loader->load($this->config); - } - - public function getCacheDir() - { - return sys_get_temp_dir().'/TestBundle'; - } - - public function serialize() - { - return $this->config; - } - - public function unserialize($config) - { - $this->__construct($config); - } -} diff --git a/tests/Functional/app/config/default.yml b/tests/Functional/app/config/default.yml deleted file mode 100644 index 8ddd7ed..0000000 --- a/tests/Functional/app/config/default.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: framework.yml } diff --git a/tests/Functional/app/config/framework.yml b/tests/Functional/app/config/framework.yml deleted file mode 100644 index 962895c..0000000 --- a/tests/Functional/app/config/framework.yml +++ /dev/null @@ -1,11 +0,0 @@ -framework: - secret: test - test: ~ - session: - storage_id: session.storage.mock_file - form: false - csrf_protection: false - validation: - enabled: false - router: - resource: "%kernel.root_dir%/config/routing.yml" diff --git a/tests/Functional/app/config/routing.yml b/tests/Functional/app/config/routing.yml deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Functional/config.yml b/tests/Functional/config.yml new file mode 100644 index 0000000..75d87b9 --- /dev/null +++ b/tests/Functional/config.yml @@ -0,0 +1,38 @@ +services: + array_cache: + class: Cache\Adapter\PHPArray\ArrayCachePool + +cache: + session: + enabled: true + service_id: 'array_cache' + use_tagging: true + ttl: 7200 + + router: + enabled: true + service_id: 'array_cache' + ttl: 86400 + + annotation: + enabled: true + service_id: 'array_cache' + use_tagging: true + + serializer: + enabled: true + service_id: 'array_cache' + use_tagging: true + + validation: + enabled: true + service_id: 'array_cache' + use_tagging: true + +framework: + annotations: + cache: 'cache.service.annotation' + serializer: + cache: 'cache.service.serializer' + validation: + cache: 'cache.service.validation' From f5ba0ae8b2b656688d84128fbce43e84e882b160 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 14:56:39 +0200 Subject: [PATCH 02/15] Updated FixedTaggingCachePool --- src/Cache/FixedTaggingCachePool.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Cache/FixedTaggingCachePool.php b/src/Cache/FixedTaggingCachePool.php index 6ed4e26..58bc170 100644 --- a/src/Cache/FixedTaggingCachePool.php +++ b/src/Cache/FixedTaggingCachePool.php @@ -20,8 +20,7 @@ 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 */ @@ -98,21 +97,27 @@ public function deleteItems(array $keys) /** * {@inheritdoc} */ - public function save(TaggableCacheItemInterface $item) + 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); } /** * {@inheritdoc} */ - public function saveDeferred(CacheItemPoolInterface $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); } From f6b9cfe8622e1bbbde558ba85ea4fb7acbc98f34 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 15:14:38 +0200 Subject: [PATCH 03/15] Using new collector --- src/Cache/Recording/CachePool.php | 297 +++++++++++------------ src/Cache/Recording/Factory.php | 4 +- src/Cache/Recording/TaggablePool.php | 30 ++- src/DataCollector/CacheDataCollector.php | 94 +++---- 4 files changed, 221 insertions(+), 204 deletions(-) diff --git a/src/Cache/Recording/CachePool.php b/src/Cache/Recording/CachePool.php index a4d0d6c..9fed604 100644 --- a/src/Cache/Recording/CachePool.php +++ b/src/Cache/Recording/CachePool.php @@ -11,7 +11,6 @@ namespace Cache\CacheBundle\Cache\Recording; -use Cache\Taggable\TaggablePoolInterface; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Psr\Log\LoggerInterface; @@ -21,231 +20,201 @@ * * @author Aaron Scherer * @author Tobias Nyholm + * @author Nicolas Grekas */ -class CachePool implements CacheItemPoolInterface, TaggablePoolInterface +class CachePool implements CacheItemPoolInterface { /** - * @type array + * @var CacheItemPoolInterface */ - private $calls = []; + protected $pool; /** - * @type CacheItemPoolInterface - */ - private $cachePool; - - /** - * @type LoggerInterface + * @var LoggerInterface */ private $logger; /** - * @type string + * @var string */ private $name; /** - * @type string + * @var string */ private $level = 'info'; /** - * LoggingCachePool constructor. - * - * @param CacheItemPoolInterface $cachePool + * @var array calls */ - public function __construct(CacheItemPoolInterface $cachePool) - { - $this->cachePool = $cachePool; - } + private $calls = array(); /** - * Record a call. - * - * @param $call + * @param CacheItemPoolInterface $pool */ - protected function addCall($call) + public function __construct(CacheItemPoolInterface $pool) { - $this->calls[] = $call; - - $this->writeLog($call); + $this->pool = $pool; } /** - * @param string $name - * @param array $arguments - * - * @return object + * {@inheritdoc} */ - protected function timeCall($name, array $arguments = []) - { - $start = microtime(true); - $result = call_user_func_array([$this->cachePool, $name], $arguments); - $time = microtime(true) - $start; - - $object = (object) compact('name', 'arguments', 'start', 'time', 'result'); - - return $object; - } - public function getItem($key) { - $call = $this->timeCall(__FUNCTION__, [$key]); - $result = $call->result; - $call->isHit = $result->isHit(); - - // Display the result in a good way depending on the data type - if ($call->isHit) { - $call->result = $this->getValueRepresentation($result->get()); + $event = $this->start(__FUNCTION__, $key); + try { + $item = $this->pool->getItem($key); + } finally { + $event->end = microtime(true); + } + if ($item->isHit()) { + ++$event->hits; } else { - $call->result = null; + ++$event->misses; } + $event->result = $item->get(); - $this->addCall($call); - - return $result; + return $item; } + /** + * {@inheritdoc} + */ public function hasItem($key) { - $call = $this->timeCall(__FUNCTION__, [$key]); - $this->addCall($call); + $event = $this->start(__FUNCTION__, $key); + try { + $event->result = $this->pool->hasItem($key); + } finally { + $event->end = microtime(true); + } + + if (!$event->result) { + ++$event->misses; + } - return $call->result; + return $event->result; } + /** + * {@inheritdoc} + */ public function deleteItem($key) { - $call = $this->timeCall(__FUNCTION__, [$key]); - $this->addCall($call); - - return $call->result; + $event = $this->start(__FUNCTION__, $key); + try { + return $event->result = $this->pool->deleteItem($key); + } finally { + $event->end = microtime(true); + } } + /** + * {@inheritdoc} + */ public function save(CacheItemInterface $item) { - $key = $item->getKey(); - $value = $this->getValueRepresentation($item->get()); - - $call = $this->timeCall(__FUNCTION__, [$item]); - $call->arguments = ['', $key, $value]; - $this->addCall($call); - - return $call->result; + $event = $this->start(__FUNCTION__, $item); + try { + return $event->result = $this->pool->save($item); + } finally { + $event->end = microtime(true); + } } + /** + * {@inheritdoc} + */ public function saveDeferred(CacheItemInterface $item) { - $key = $item->getKey(); - $value = $this->getValueRepresentation($item->get()); - - $call = $this->timeCall(__FUNCTION__, [$item]); - $call->arguments = ['', $key, $value]; - $this->addCall($call); - - return $call->result; + $event = $this->start(__FUNCTION__, $item); + try { + return $event->result = $this->pool->saveDeferred($item); + } finally { + $event->end = microtime(true); + } } - public function getItems(array $keys = []) + /** + * {@inheritdoc} + */ + public function getItems(array $keys = array()) { - $call = $this->timeCall(__FUNCTION__, [$keys]); - $result = $call->result; - $call->result = sprintf('', gettype($result)); - $this->addCall($call); - - return $result; + $event = $this->start(__FUNCTION__, $keys); + try { + $result = $this->pool->getItems($keys); + } finally { + $event->end = microtime(true); + } + $f = function () use ($result, $event) { + $event->result = array(); + foreach ($result as $key => $item) { + if ($item->isHit()) { + ++$event->hits; + } else { + ++$event->misses; + } + $event->result[$key] = $item->get(); + yield $key => $item; + } + }; + + return $f(); } + /** + * {@inheritdoc} + */ public function clear() { - $call = $this->timeCall(__FUNCTION__, []); - $this->addCall($call); - - return $call->result; - } - - public function clearTags(array $tags) - { - $call = $this->timeCall(__FUNCTION__, [$tags]); - $this->addCall($call); - - return $call->result; + $event = $this->start(__FUNCTION__); + try { + return $event->result = $this->pool->clear(); + } finally { + $event->end = microtime(true); + } } + /** + * {@inheritdoc} + */ public function deleteItems(array $keys) { - $call = $this->timeCall(__FUNCTION__, [$keys]); - $this->addCall($call); - - return $call->result; + $event = $this->start(__FUNCTION__, $keys); + try { + return $event->result = $this->pool->deleteItems($keys); + } finally { + $event->end = microtime(true); + } } + /** + * {@inheritdoc} + */ public function commit() { - $call = $this->timeCall(__FUNCTION__); - $this->addCall($call); - - return $call->result; + $event = $this->start(__FUNCTION__); + try { + return $event->result = $this->pool->commit(); + } finally { + $event->end = microtime(true); + } } - /** - * @return array - */ public function getCalls() { return $this->calls; } - /** - * Get a string to represent the value. - * - * @param mixed $value - * - * @return string - */ - private function getValueRepresentation($value) - { - $type = gettype($value); - if (in_array($type, ['boolean', 'integer', 'double', 'string', 'NULL'])) { - $rep = $value; - } elseif ($type === 'array') { - $rep = json_encode($value); - } elseif ($type === 'object') { - $rep = get_class($value); - } else { - $rep = sprintf('', $type); - } - - return $rep; - } - - protected function writeLog($call) + protected function start($name, $argument = null) { - if (!$this->logger) { - return; - } + $this->calls[] = $event = new TraceableAdapterEvent(); + $event->name = $name; + $event->argument = $argument; + $event->start = microtime(true); - $data = [ - 'name' => $this->name, - 'method' => $call->name, - 'arguments' => json_encode($call->arguments), - 'hit' => isset($call->isHit) ? $call->isHit ? 'True' : 'False' : 'Invalid', - 'time' => round($call->time * 1000, 2), - 'result' => $call->result, - ]; - - $this->logger->log( - $this->level, - sprintf('[Cache] Provider: %s. Method: %s(%s). Hit: %s. Time: %sms. Result: %s', - $data['name'], - $data['method'], - $data['arguments'], - $data['hit'], - $data['time'], - $data['result'] - ), - $data - ); + return $event; } /** @@ -266,6 +235,14 @@ public function setName($name) return $this; } + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + /** * @param string $level */ @@ -276,3 +253,17 @@ public function setLevel($level) return $this; } } + +/** + * @internal + */ +class TraceableAdapterEvent +{ + public $name; + public $argument; + public $start; + public $end; + public $result; + public $hits = 0; + public $misses = 0; +} diff --git a/src/Cache/Recording/Factory.php b/src/Cache/Recording/Factory.php index c09ec4f..8d29ac7 100644 --- a/src/Cache/Recording/Factory.php +++ b/src/Cache/Recording/Factory.php @@ -53,9 +53,9 @@ public function __construct(LoggerInterface $logger = null, $level = null) */ public function create($name, CacheItemPoolInterface $pool) { - if ($pool instanceof TaggablePoolInterface && $pool instanceof HierarchicalPoolInterface) { + if ($pool instanceof TaggableCacheItemPoolInterface && $pool instanceof HierarchicalPoolInterface) { $recorder = new HierarchyAndTaggablePool($pool); - } elseif ($pool instanceof TaggablePoolInterface) { + } elseif ($pool instanceof TaggableCacheItemPoolInterface) { $recorder = new TaggablePool($pool); } elseif ($pool instanceof HierarchicalPoolInterface) { $recorder = new HierarchyPool($pool); diff --git a/src/Cache/Recording/TaggablePool.php b/src/Cache/Recording/TaggablePool.php index b0f2a10..091e9fe 100644 --- a/src/Cache/Recording/TaggablePool.php +++ b/src/Cache/Recording/TaggablePool.php @@ -11,18 +11,36 @@ namespace Cache\CacheBundle\Cache\Recording; -use Cache\Taggable\TaggablePoolInterface; +use Cache\TagInterop\TaggableCacheItemPoolInterface; /** * @author Tobias Nyholm */ -class TaggablePool extends CachePool implements TaggablePoolInterface +class TaggablePool extends CachePool implements TaggableCacheItemPoolInterface { - public function clearTags(array $tags) + /** + * {@inheritdoc} + */ + public function invalidateTag($tag) { - $call = $this->timeCall(__FUNCTION__, [$tags]); - $this->addCall($call); + $event = $this->start(__FUNCTION__, $tag); + try { + return $event->result = $this->pool->invalidateTag($tag); + } finally { + $event->end = microtime(true); + } + } - return $call->result; + /** + * {@inheritdoc} + */ + public function invalidateTags(array $tags) + { + $event = $this->start(__FUNCTION__, $tags); + try { + return $event->result = $this->pool->invalidateTags($tags); + } finally { + $event->end = microtime(true); + } } } diff --git a/src/DataCollector/CacheDataCollector.php b/src/DataCollector/CacheDataCollector.php index 282421b..a0b2772 100644 --- a/src/DataCollector/CacheDataCollector.php +++ b/src/DataCollector/CacheDataCollector.php @@ -12,14 +12,14 @@ namespace Cache\CacheBundle\DataCollector; use Cache\CacheBundle\Cache\Recording\CachePool; +use Cache\CacheBundle\Cache\Recording\TraceableAdapterEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; /** - * Class CacheDataCollector. - * * @author Aaron Scherer + * @author Tobias Nyholm */ class CacheDataCollector extends DataCollector { @@ -31,46 +31,38 @@ class CacheDataCollector extends DataCollector const TEMPLATE = 'CacheBundle:Collector:cache.html.twig'; /** - * @type CachePool[] + * @var CachePool[] */ - private $instances = []; + private $instances = array(); /** - * @param string $name + * @param string $name * @param CachePool $instance */ - public function addInstance($name, CachePool $instance) + public function addInstance(CachePool $instance) { - $this->instances[$name] = $instance; + $this->instances[$instance->getName()] = $instance; } /** - * Collects data for the given Request and Response. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * @param \Exception $exception An Exception instance - * - * @api + * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { - $empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []]; - $this->data = ['instances' => $empty, 'total' => $empty]; + $empty = array('calls' => array(), 'config' => array(), 'options' => array(), 'statistics' => array()); + $this->data = array('instances' => $empty, 'total' => $empty); foreach ($this->instances as $name => $instance) { $this->data['instances']['calls'][$name] = $instance->getCalls(); } $this->data['instances']['statistics'] = $this->calculateStatistics(); - $this->data['total']['statistics'] = $this->calculateTotalStatistics(); + $this->data['total']['statistics'] = $this->calculateTotalStatistics(); + + $this->data = $this->cloneVar($this->data); } /** - * Returns the name of the collector. - * - * @return string The collector name - * - * @api + * {@inheritdoc} */ public function getName() { @@ -112,42 +104,50 @@ public function getCalls() */ private function calculateStatistics() { - $statistics = []; + $statistics = array(); foreach ($this->data['instances']['calls'] as $name => $calls) { - $statistics[$name] = [ - 'calls' => 0, - 'time' => 0, - 'reads' => 0, - 'hits' => 0, - 'misses' => 0, - 'writes' => 0, + $statistics[$name] = array( + 'calls' => 0, + 'time' => 0, + 'reads' => 0, + 'writes' => 0, 'deletes' => 0, - ]; + 'hits' => 0, + 'misses' => 0, + ); + /** @var TraceableAdapterEvent $call */ foreach ($calls as $call) { $statistics[$name]['calls'] += 1; - $statistics[$name]['time'] += $call->time; - if ($call->name === 'getItem') { + $statistics[$name]['time'] += $call->end - $call->start; + if ('getItem' === $call->name) { $statistics[$name]['reads'] += 1; - if ($call->isHit) { + if ($call->hits) { $statistics[$name]['hits'] += 1; } else { $statistics[$name]['misses'] += 1; } - } elseif ($call->name === 'hasItem') { + } elseif ('getItems' === $call->name) { + $count = $call->hits + $call->misses; + $statistics[$name]['reads'] += $count; + $statistics[$name]['hits'] += $call->hits; + $statistics[$name]['misses'] += $count - $call->misses; + } elseif ('hasItem' === $call->name) { $statistics[$name]['reads'] += 1; - if ($call->result === false) { + if (false === $call->result) { $statistics[$name]['misses'] += 1; + } else { + $statistics[$name]['hits'] += 1; } - } elseif ($call->name === 'save') { + } elseif ('save' === $call->name) { $statistics[$name]['writes'] += 1; - } elseif ($call->name === 'deleteItem') { + } elseif ('deleteItem' === $call->name) { $statistics[$name]['deletes'] += 1; } } if ($statistics[$name]['reads']) { - $statistics[$name]['ratio'] = round(100 * $statistics[$name]['hits'] / $statistics[$name]['reads'], 2).'%'; + $statistics[$name]['hit_read_ratio'] = round(100 * $statistics[$name]['hits'] / $statistics[$name]['reads'], 2); } else { - $statistics[$name]['ratio'] = 'N/A'; + $statistics[$name]['hit_read_ratio'] = null; } } @@ -160,16 +160,24 @@ private function calculateStatistics() private function calculateTotalStatistics() { $statistics = $this->getStatistics(); - $totals = ['calls' => 0, 'time' => 0, 'reads' => 0, 'hits' => 0, 'misses' => 0, 'writes' => 0]; + $totals = array( + 'calls' => 0, + 'time' => 0, + 'reads' => 0, + 'writes' => 0, + 'deletes' => 0, + 'hits' => 0, + 'misses' => 0, + ); foreach ($statistics as $name => $values) { foreach ($totals as $key => $value) { $totals[$key] += $statistics[$name][$key]; } } if ($totals['reads']) { - $totals['ratio'] = round(100 * $totals['hits'] / $totals['reads'], 2).'%'; + $totals['hit_read_ratio'] = round(100 * $totals['hits'] / $totals['reads'], 2); } else { - $totals['ratio'] = 'N/A'; + $totals['hit_read_ratio'] = null; } return $totals; From 02e1e8cdeababdafebd72f78bff0f9c8fb15a465 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 15:33:12 +0200 Subject: [PATCH 04/15] Fixes --- src/DataCollector/CacheDataCollector.php | 6 +++--- src/DependencyInjection/CacheExtension.php | 4 ++-- src/Factory/DoctrineBridgeFactory.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DataCollector/CacheDataCollector.php b/src/DataCollector/CacheDataCollector.php index a0b2772..f96380b 100644 --- a/src/DataCollector/CacheDataCollector.php +++ b/src/DataCollector/CacheDataCollector.php @@ -36,12 +36,12 @@ class CacheDataCollector extends DataCollector private $instances = array(); /** - * @param string $name + * @param string $name * @param CachePool $instance */ - public function addInstance(CachePool $instance) + public function addInstance($name, CachePool $instance) { - $this->instances[$instance->getName()] = $instance; + $this->instances[$name] = $instance; } /** diff --git a/src/DependencyInjection/CacheExtension.php b/src/DependencyInjection/CacheExtension.php index c3cdd7c..29a4303 100644 --- a/src/DependencyInjection/CacheExtension.php +++ b/src/DependencyInjection/CacheExtension.php @@ -92,9 +92,9 @@ protected function findServiceIds(array $config, array &$serviceIds) */ private function verifyDoctrineBridgeExists($name) { - if (!class_exists('Cache\Bridge\DoctrineCacheBridge')) { + if (!class_exists('Cache\Bridge\Doctrine\DoctrineCacheBridge')) { throw new \Exception(sprintf( - 'You need the DoctrineBridge to be able to use "%s". Please run "composer require cache/psr-6-doctrine-bridge" to install the missing dependency.', + 'You need the DoctrineCacheBridge to be able to use "%s". Please run "composer require cache/psr-6-doctrine-bridge" to install the missing dependency.', $name )); } diff --git a/src/Factory/DoctrineBridgeFactory.php b/src/Factory/DoctrineBridgeFactory.php index f7cde98..abe35f8 100644 --- a/src/Factory/DoctrineBridgeFactory.php +++ b/src/Factory/DoctrineBridgeFactory.php @@ -11,7 +11,7 @@ namespace Cache\CacheBundle\Factory; -use Cache\Bridge\DoctrineCacheBridge; +use Cache\Bridge\Doctrine\DoctrineCacheBridge; use Cache\CacheBundle\Cache\FixedTaggingCachePool; use Cache\Taggable\TaggablePSR6PoolAdapter; use Psr\Cache\CacheItemPoolInterface; From f55a46fd5ef121d1c0d8c2b129b3a01a2694c05a Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 15:45:20 +0200 Subject: [PATCH 05/15] Updating to nicer profiler page --- src/DataCollector/CacheDataCollector.php | 9 +- src/Resources/config/data-collector.yml | 2 +- src/Resources/views/Collector/cache.html.twig | 206 +++++++++++------- 3 files changed, 132 insertions(+), 85 deletions(-) diff --git a/src/DataCollector/CacheDataCollector.php b/src/DataCollector/CacheDataCollector.php index f96380b..429ea9d 100644 --- a/src/DataCollector/CacheDataCollector.php +++ b/src/DataCollector/CacheDataCollector.php @@ -23,13 +23,6 @@ */ class CacheDataCollector extends DataCollector { - /** - * Template name. - * - * @type string - */ - const TEMPLATE = 'CacheBundle:Collector:cache.html.twig'; - /** * @var CachePool[] */ @@ -66,7 +59,7 @@ public function collect(Request $request, Response $response, \Exception $except */ public function getName() { - return 'cache'; + return 'php-cache'; } /** diff --git a/src/Resources/config/data-collector.yml b/src/Resources/config/data-collector.yml index b921338..48d9fc3 100644 --- a/src/Resources/config/data-collector.yml +++ b/src/Resources/config/data-collector.yml @@ -2,4 +2,4 @@ services: cache.data_collector: class: Cache\CacheBundle\DataCollector\CacheDataCollector tags: - - { name: data_collector, template: 'CacheBundle:Collector:cache.html.twig', id: 'cache' } + - { name: data_collector, template: 'CacheBundle:Collector:cache.html.twig', id: 'php-cache' } diff --git a/src/Resources/views/Collector/cache.html.twig b/src/Resources/views/Collector/cache.html.twig index 6f46646..9d7d0ae 100644 --- a/src/Resources/views/Collector/cache.html.twig +++ b/src/Resources/views/Collector/cache.html.twig @@ -7,16 +7,7 @@ # with this source code in the file LICENSE. #} -{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %} - -{% block head %} - {{ parent() }} - -{% endblock head %} +{% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} {% if collector.totals.calls > 0 %} @@ -30,22 +21,22 @@ {% endset %} {% set text %} -
- Cache Calls - {{ collector.totals.calls }} -
-
- Total time - {{ '%0.2f'|format(collector.totals.time * 1000) }} ms -
-
- Cache hits - {{ collector.totals.hits }}/{{ collector.totals.reads }} ({{ collector.totals.ratio }}) -
-
- Cache writes - {{ collector.totals.writes }} -
+
+ Cache Calls + {{ collector.totals.calls }} +
+
+ Total time + {{ '%0.2f'|format(collector.totals.time * 1000) }} ms +
+
+ Cache hits + {{ collector.totals.hits }}/{{ collector.totals.reads }}{% if collector.totals.hit_read_ratio is not null %} ({{ collector.totals.hit_read_ratio }}%){% endif %} +
+
+ Cache writes + {{ collector.totals.writes }} +
{% endset %} {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %} {% endif %} @@ -56,65 +47,128 @@ {{ include('@Cache/Icon/logo.svg') }} - Cache + PHPCache {{ collector.totals.calls }} - {{ '%0.0f'|format(collector.totals.time * 1000) }} ms + {{ '%0.2f'|format(collector.totals.time * 1000) }} ms {% endblock %} {% block panel %} -

Cache

- {% for name, calls in collector.calls %} -

Statistics for '{{ name }}'

- - - - {% for key, value in collector.statistics[name] %} - - {% endfor %} - - - - - {% for key, value in collector.statistics[name] %} - {% if key == 'time' %} - - {% else %} - - {% endif %} - {% endfor %} - - -
{{ key|capitalize }}
{{ '%0.2f'|format(value * 1000) }} ms{{ value }}
+

PHPCache

+
+
+ {{ collector.totals.calls }} + Total calls +
+
+ {{ '%0.2f'|format(collector.totals.time * 1000) }} ms + Total time +
+
+
+ {{ collector.totals.reads }} + Total reads +
+
+ {{ collector.totals.writes }} + Total writes +
+
+ {{ collector.totals.deletes }} + Total deletes +
+
+
+ {{ collector.totals.hits }} + Total hits +
+
+ {{ collector.totals.misses }} + Total misses +
+
+ + {% if collector.totals.hit_read_ratio is null %} + n/a + {% else %} + {{ collector.totals.hit_read_ratio }} % + {% endif %} + + Hits/reads +
+
+ +

Pools

+
+ {% for name, calls in collector.calls %} +
+

{{ name }} {{ collector.statistics[name].calls }}

-

Calls for '{{ name }}'

+
+

Statistics

+
+ {% for key, value in collector.statistics[name] %} +
+ + {% if key == 'time' %} + {{ '%0.2f'|format(1000 * value.value) }} ms + {% elseif key == 'hit_read_ratio' %} + {% if value.value is null %} + n/a + {% else %} + {{ value }} % + {% endif %} + {% else %} + {{ value }} + {% endif %} + + {{ key == 'hit_read_ratio' ? 'Hits/reads' : key|capitalize }} +
+ {% if key == 'time' or key == 'deletes' %} +
+ {% endif %} + {% endfor %} +
- {% if not collector.totals.calls %} -

- No calls. -

- {% else %} -
    - {% for i, call in calls %} -
  • -
    - Name: {{ call.name }}
    - Arguments: {{ call.arguments|json_encode[:140] }}
    - Results: {% if call.result == false %} - Miss - {% else %} - {{ call.result[:140] }} - {% endif %}
    +

    Calls

    + {% if calls|length == 0 %} +
    +

    No calls

    - - Time: {{ '%0.2f'|format(call.time * 1000) }} ms - -
  • - {% endfor %} -
- {% endif %} - {% endfor %} + {% else %} + + + + + + + + + + {% for call in calls %} + {% set separatorStyle = not loop.first ? ' style="border-top-width: medium;"' : '' %} + + + {{ call.name }} + {{ profiler_dump(call.value.argument, maxDepth=2) }} + + + + + + + + + + {% endfor %} + +
#KeyValue
{{ loop.index }}
Result{{ profiler_dump(call.value.result, maxDepth=1) }}
Time{{ '%0.2f'|format((call.end - call.start) * 1000) }} ms
+ {% endif %} +
+
+ {% endfor %} +
{% endblock %} From 701f2d017914d8564b7b48e0ecf37c157e9a54ba Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 15:46:23 +0200 Subject: [PATCH 06/15] Minor --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f2b6297..dc4171e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ env: matrix: - SYMFONY_VERSION=2.7.* - SYMFONY_VERSION=2.8.* + - SYMFONY_VERSION=3.0.* + - SYMFONY_VERSION=3.1.* - SYMFONY_VERSION=3.2.* branches: @@ -36,7 +38,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: From 9e98b397b73fecf1c35fccae41cc3774b3e210fb Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 15:48:23 +0200 Subject: [PATCH 07/15] cs --- src/Cache/FixedTaggingCachePool.php | 7 ++-- src/Cache/Recording/CachePool.php | 24 ++++++------- src/Cache/Recording/Factory.php | 1 - src/DataCollector/CacheDataCollector.php | 46 ++++++++++++------------ 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/Cache/FixedTaggingCachePool.php b/src/Cache/FixedTaggingCachePool.php index 58bc170..8d3287f 100644 --- a/src/Cache/FixedTaggingCachePool.php +++ b/src/Cache/FixedTaggingCachePool.php @@ -11,12 +11,9 @@ 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; /** @@ -38,7 +35,7 @@ class FixedTaggingCachePool implements TaggableCacheItemPoolInterface /** * @param TaggableCacheItemPoolInterface $cache - * @param array $tags + * @param array $tags */ public function __construct(TaggableCacheItemPoolInterface $cache, array $tags) { @@ -143,6 +140,6 @@ public function invalidateTag($tag) */ public function invalidateTags(array $tags) { - return $this->cache-$this->invalidateTags($tags); + return $this->cache - $this->invalidateTags($tags); } } diff --git a/src/Cache/Recording/CachePool.php b/src/Cache/Recording/CachePool.php index 9fed604..410b921 100644 --- a/src/Cache/Recording/CachePool.php +++ b/src/Cache/Recording/CachePool.php @@ -25,29 +25,29 @@ class CachePool implements CacheItemPoolInterface { /** - * @var CacheItemPoolInterface + * @type CacheItemPoolInterface */ protected $pool; /** - * @var LoggerInterface + * @type LoggerInterface */ private $logger; /** - * @var string + * @type string */ private $name; /** - * @var string + * @type string */ private $level = 'info'; /** - * @var array calls + * @type array calls */ - private $calls = array(); + private $calls = []; /** * @param CacheItemPoolInterface $pool @@ -139,7 +139,7 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { $event = $this->start(__FUNCTION__, $keys); try { @@ -148,7 +148,7 @@ public function getItems(array $keys = array()) $event->end = microtime(true); } $f = function () use ($result, $event) { - $event->result = array(); + $event->result = []; foreach ($result as $key => $item) { if ($item->isHit()) { ++$event->hits; @@ -209,10 +209,10 @@ public function getCalls() protected function start($name, $argument = null) { - $this->calls[] = $event = new TraceableAdapterEvent(); - $event->name = $name; + $this->calls[] = $event = new TraceableAdapterEvent(); + $event->name = $name; $event->argument = $argument; - $event->start = microtime(true); + $event->start = microtime(true); return $event; } @@ -264,6 +264,6 @@ class TraceableAdapterEvent public $start; public $end; public $result; - public $hits = 0; + public $hits = 0; public $misses = 0; } diff --git a/src/Cache/Recording/Factory.php b/src/Cache/Recording/Factory.php index 8d29ac7..a59385a 100644 --- a/src/Cache/Recording/Factory.php +++ b/src/Cache/Recording/Factory.php @@ -12,7 +12,6 @@ namespace Cache\CacheBundle\Cache\Recording; use Cache\Hierarchy\HierarchicalPoolInterface; -use Cache\Taggable\TaggablePoolInterface; use Psr\Cache\CacheItemPoolInterface; use Psr\Log\LoggerInterface; diff --git a/src/DataCollector/CacheDataCollector.php b/src/DataCollector/CacheDataCollector.php index 429ea9d..935321f 100644 --- a/src/DataCollector/CacheDataCollector.php +++ b/src/DataCollector/CacheDataCollector.php @@ -24,9 +24,9 @@ class CacheDataCollector extends DataCollector { /** - * @var CachePool[] + * @type CachePool[] */ - private $instances = array(); + private $instances = []; /** * @param string $name @@ -42,14 +42,14 @@ public function addInstance($name, CachePool $instance) */ public function collect(Request $request, Response $response, \Exception $exception = null) { - $empty = array('calls' => array(), 'config' => array(), 'options' => array(), 'statistics' => array()); - $this->data = array('instances' => $empty, 'total' => $empty); + $empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []]; + $this->data = ['instances' => $empty, 'total' => $empty]; foreach ($this->instances as $name => $instance) { $this->data['instances']['calls'][$name] = $instance->getCalls(); } $this->data['instances']['statistics'] = $this->calculateStatistics(); - $this->data['total']['statistics'] = $this->calculateTotalStatistics(); + $this->data['total']['statistics'] = $this->calculateTotalStatistics(); $this->data = $this->cloneVar($this->data); } @@ -97,18 +97,18 @@ public function getCalls() */ private function calculateStatistics() { - $statistics = array(); + $statistics = []; foreach ($this->data['instances']['calls'] as $name => $calls) { - $statistics[$name] = array( - 'calls' => 0, - 'time' => 0, - 'reads' => 0, - 'writes' => 0, + $statistics[$name] = [ + 'calls' => 0, + 'time' => 0, + 'reads' => 0, + 'writes' => 0, 'deletes' => 0, - 'hits' => 0, - 'misses' => 0, - ); - /** @var TraceableAdapterEvent $call */ + 'hits' => 0, + 'misses' => 0, + ]; + /** @type TraceableAdapterEvent $call */ foreach ($calls as $call) { $statistics[$name]['calls'] += 1; $statistics[$name]['time'] += $call->end - $call->start; @@ -153,15 +153,15 @@ private function calculateStatistics() private function calculateTotalStatistics() { $statistics = $this->getStatistics(); - $totals = array( - 'calls' => 0, - 'time' => 0, - 'reads' => 0, - 'writes' => 0, + $totals = [ + 'calls' => 0, + 'time' => 0, + 'reads' => 0, + 'writes' => 0, 'deletes' => 0, - 'hits' => 0, - 'misses' => 0, - ); + 'hits' => 0, + 'misses' => 0, + ]; foreach ($statistics as $name => $values) { foreach ($totals as $key => $value) { $totals[$key] += $statistics[$name][$key]; From 1c2007ea7bae8e702d763fe70c34cac437c1c205 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 16:36:34 +0200 Subject: [PATCH 08/15] Make sure we support sf < 3.3 --- src/DataCollector/CacheDataCollector.php | 2 -- src/Resources/views/Collector/cache.html.twig | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/DataCollector/CacheDataCollector.php b/src/DataCollector/CacheDataCollector.php index 935321f..39f469d 100644 --- a/src/DataCollector/CacheDataCollector.php +++ b/src/DataCollector/CacheDataCollector.php @@ -50,8 +50,6 @@ public function collect(Request $request, Response $response, \Exception $except $this->data['instances']['statistics'] = $this->calculateStatistics(); $this->data['total']['statistics'] = $this->calculateTotalStatistics(); - - $this->data = $this->cloneVar($this->data); } /** diff --git a/src/Resources/views/Collector/cache.html.twig b/src/Resources/views/Collector/cache.html.twig index 9d7d0ae..fbe8e83 100644 --- a/src/Resources/views/Collector/cache.html.twig +++ b/src/Resources/views/Collector/cache.html.twig @@ -113,9 +113,9 @@
{% if key == 'time' %} - {{ '%0.2f'|format(1000 * value.value) }} ms + {{ '%0.2f'|format(1000 * value) }} ms {% elseif key == 'hit_read_ratio' %} - {% if value.value is null %} + {% if value is null %} n/a {% else %} {{ value }} % @@ -152,11 +152,11 @@ {{ loop.index }} {{ call.name }} - {{ profiler_dump(call.value.argument, maxDepth=2) }} + {{ dump(call.argument) }} Result - {{ profiler_dump(call.value.result, maxDepth=1) }} + {{ dump(call.result) }} Time From 65e672ad779bd74cde7c30f3a2be045dc2bfcba8 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 16:40:38 +0200 Subject: [PATCH 09/15] minor --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index eb71ba3..a60cb59 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "require-dev": { "phpunit/phpunit": "^5.1 || ^4.0", "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" From be2593fbb1ad8b127a44e6c552bca6ae2513e583 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 16:47:37 +0200 Subject: [PATCH 10/15] Bugfix and more tests --- src/Cache/Recording/CachePool.php | 8 -------- src/DependencyInjection/CacheExtension.php | 2 +- tests/Functional/BundleInitializationTest.php | 9 +++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Cache/Recording/CachePool.php b/src/Cache/Recording/CachePool.php index 410b921..6be2208 100644 --- a/src/Cache/Recording/CachePool.php +++ b/src/Cache/Recording/CachePool.php @@ -235,14 +235,6 @@ public function setName($name) return $this; } - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - /** * @param string $level */ diff --git a/src/DependencyInjection/CacheExtension.php b/src/DependencyInjection/CacheExtension.php index 29a4303..7840578 100644 --- a/src/DependencyInjection/CacheExtension.php +++ b/src/DependencyInjection/CacheExtension.php @@ -11,7 +11,7 @@ namespace Cache\CacheBundle\DependencyInjection; -use Cache\Bridge\DoctrineCacheBridge; +use Cache\Bridge\Doctrine\DoctrineCacheBridge; use Cache\CacheBundle\Bridge\SymfonyValidatorBridge; use Cache\CacheBundle\Factory\DoctrineBridgeFactory; use Cache\CacheBundle\Factory\SessionHandlerFactory; diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php index 15eb7e6..3c68720 100644 --- a/tests/Functional/BundleInitializationTest.php +++ b/tests/Functional/BundleInitializationTest.php @@ -11,7 +11,11 @@ namespace Cache\CacheBundle\Tests\Functional; +use Cache\Bridge\Doctrine\DoctrineCacheBridge; +use Cache\CacheBundle\Bridge\SymfonyValidatorBridge; use Cache\CacheBundle\CacheBundle; +use Cache\CacheBundle\Routing\CachingRouter; +use Cache\SessionHandler\Psr6SessionHandler; use Nyholm\BundleTest\BaseBundleTestCase; /** @@ -37,5 +41,10 @@ public function testInitBundle() $container = $this->getContainer(); $this->assertTrue($container->hasParameter('cache.provider_service_ids')); + $this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.annotation')); + $this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.serializer')); + $this->assertInstanceOf(SymfonyValidatorBridge::class, $container->get('cache.service.validation')); + $this->assertInstanceOf(Psr6SessionHandler::class, $container->get('cache.service.session')); + $this->assertInstanceOf(CachingRouter::class, $container->get('cache.service.router')); } } From ab3e5f617d48b0aeadb92a0b190895d0dc991282 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 16:56:04 +0200 Subject: [PATCH 11/15] Namespace update --- src/DependencyInjection/Compiler/DoctrineCompilerPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DependencyInjection/Compiler/DoctrineCompilerPass.php b/src/DependencyInjection/Compiler/DoctrineCompilerPass.php index 8af299d..b66fb33 100644 --- a/src/DependencyInjection/Compiler/DoctrineCompilerPass.php +++ b/src/DependencyInjection/Compiler/DoctrineCompilerPass.php @@ -11,7 +11,7 @@ namespace Cache\CacheBundle\DependencyInjection\Compiler; -use Cache\Bridge\DoctrineCacheBridge; +use Cache\Bridge\Doctrine\DoctrineCacheBridge; use Cache\CacheBundle\Factory\DoctrineBridgeFactory; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; From 06677a563b5031af5908f1f8883fef86b4828634 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 16:56:46 +0200 Subject: [PATCH 12/15] Remove support for PHP 5.5 --- .travis.yml | 2 -- composer.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc4171e..f51a0a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ php: - 7.1 - 7.0 - 5.6 - - 5.5 - hhvm env: @@ -16,7 +15,6 @@ env: matrix: - SYMFONY_VERSION=2.7.* - SYMFONY_VERSION=2.8.* - - SYMFONY_VERSION=3.0.* - SYMFONY_VERSION=3.1.* - SYMFONY_VERSION=3.2.* diff --git a/composer.json b/composer.json index a60cb59..710184e 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } ], "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" From 3257628d84a4dda39dbd0c0cfd9677ccc1c48fd4 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 16:57:14 +0200 Subject: [PATCH 13/15] Minor --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f51a0a3..4431675 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: From 9fd8b4b01df39b4bd3490208db2655fec4b9b880 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 17:15:13 +0200 Subject: [PATCH 14/15] Added change log --- Changelog.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Changelog.md b/Changelog.md index f4fe833..9721120 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 From b19b67862c8a1b851d1d3b6ecbabb710f8f84758 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 28 Mar 2017 17:15:26 +0200 Subject: [PATCH 15/15] Do not require old phpunit versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 710184e..e867685 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "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": "^3.0", "cache/array-adapter": "^0.5",