From 9b9bb7c2485c33f3cb794099e5cfd06222a5d232 Mon Sep 17 00:00:00 2001 From: Alex Pavlov Date: Tue, 14 Mar 2017 21:46:28 +0300 Subject: [PATCH 1/2] Update doc. Remove class `ApcCache` from doc Class `ApcCache` was deprecated since 2.8 and removed from 3.0 version. Update doc. --- components/validator/resources.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 37581c0c2ed..bbc1bb850ba 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -150,9 +150,7 @@ can slow down your application because each file needs to be parsed, validated and converted into a :class:`Symfony\\Component\\Validator\\Mapping\\ClassMetadata` instance. To solve this problem, you can cache the ``ClassMetadata`` information. -The Validator component comes with an -:class:`Symfony\\Component\\Validator\\Mapping\\Cache\\ApcCache` -implementation. You can easily create other cachers by creating a class which +You can easily create cachers by creating a class which implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`. .. note:: @@ -168,11 +166,10 @@ Enable the cache calling the method of the Validator builder:: use Symfony\Component\Validator\Validation; - use Symfony\Component\Validator\Mapping\Cache\ApcCache; $validator = Validation::createValidatorBuilder() // ... add loaders - ->setMetadataCache(new ApcCache('some_apc_prefix')); + ->setMetadataCache(new SomeImplementCacheInterface()); ->getValidator(); Using a Custom MetadataFactory From 7d4a554a91450aceceff4a16ccaf2e03ba60e779 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 15 Mar 2017 10:28:50 +0100 Subject: [PATCH 2/2] Minor reword --- components/validator/resources.rst | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/components/validator/resources.rst b/components/validator/resources.rst index bbc1bb850ba..b5f89051d01 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -148,10 +148,18 @@ Caching Using many loaders to load metadata from different places is convenient, but it can slow down your application because each file needs to be parsed, validated and converted into a :class:`Symfony\\Component\\Validator\\Mapping\\ClassMetadata` -instance. To solve this problem, you can cache the ``ClassMetadata`` information. +instance. -You can easily create cachers by creating a class which -implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`. +To solve this problem, call the :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache` +method of the Validator builder and pass your own caching class (which must +implement :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`):: + + use Symfony\Component\Validator\Validation; + + $validator = Validation::createValidatorBuilder() + // ... add loaders + ->setMetadataCache(new SomeImplementCacheInterface()); + ->getValidator(); .. note:: @@ -161,17 +169,6 @@ implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface the Validator still needs to merge all metadata of one class from every loader when it is requested. -Enable the cache calling the -:method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache` -method of the Validator builder:: - - use Symfony\Component\Validator\Validation; - - $validator = Validation::createValidatorBuilder() - // ... add loaders - ->setMetadataCache(new SomeImplementCacheInterface()); - ->getValidator(); - Using a Custom MetadataFactory ------------------------------