From 79a27d5b3ad9e359bce328edf8643999c02622d9 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Fri, 25 Jun 2021 11:30:09 +0300 Subject: [PATCH] Use PsrCachedReader and drop doctrine/cache --- UPGRADING.md | 5 +++++ composer.json | 2 +- src/SerializerBuilder.php | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 7f023908f..990ceeebd 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,3 +1,8 @@ +Unreleased +========== + +- Use symfony/cache for FileSystem cache implementation instead of doctrine/cache + From 2.x to 3.0.0 ================= diff --git a/composer.json b/composer.json index a3440e215..e9fb2430d 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ "phpstan/phpdoc-parser": "^0.4 || ^0.5" }, "suggest": { - "doctrine/cache": "Required if you like to use cache functionality.", "doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.", + "symfony/cache": "Required if you like to use cache functionality.", "symfony/yaml": "Required if you'd like to use the YAML metadata format." }, "require-dev": { diff --git a/src/SerializerBuilder.php b/src/SerializerBuilder.php index 4a9255657..5bdbec2fa 100644 --- a/src/SerializerBuilder.php +++ b/src/SerializerBuilder.php @@ -5,9 +5,8 @@ namespace JMS\Serializer; use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\CachedReader; +use Doctrine\Common\Annotations\PsrCachedReader; use Doctrine\Common\Annotations\Reader; -use Doctrine\Common\Cache\FilesystemCache; use JMS\Serializer\Accessor\AccessorStrategyInterface; use JMS\Serializer\Accessor\DefaultAccessorStrategy; use JMS\Serializer\Builder\DefaultDriverFactory; @@ -50,6 +49,7 @@ use Metadata\Cache\FileCache; use Metadata\MetadataFactory; use Metadata\MetadataFactoryInterface; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; /** * Builder for serializer instances. @@ -525,8 +525,8 @@ public function build(): Serializer if (null !== $this->cacheDir) { $this->createDir($this->cacheDir . '/annotations'); - $annotationsCache = new FilesystemCache($this->cacheDir . '/annotations'); - $annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug); + $annotationsCache = new FilesystemAdapter('', 0, $this->cacheDir . '/annotations'); + $annotationReader = new PsrCachedReader($annotationReader, $annotationsCache, $this->debug); } }