Using JMSSerializerBundle v3.0.0, I figured out how to use apcu caching for annotations and metadata when creating a new serializer from SerializerBuilder::create()
.
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use JMS\Serializer\SerializerBuilder;
public function createSerializer()
{
$cache = new ApcuCache();
return SerializerBuilder::create()
->setPropertyNamingStrategy(new SerializedNameAnnotationStrategy(new IdenticalPropertyNamingStrategy()))
->addDefaultHandlers()
->setAnnotationReader(new CachedReader(new AnnotationReader(), $cache, false))
->setMetadataCache(new DoctrineCacheAdapter('JMS_METADATA_', $cache))
->build();
}
But I can't find a way to do that for the dependency injected serializer. The documentation mention:
metadata:
cache: file
but nothing about setting it to apcu cache and nothing about user a cached annotation reader.
Anybody already implemented it?