@@ -148,10 +148,18 @@ Caching
148148Using many loaders to load metadata from different places is convenient, but it
149149can slow down your application because each file needs to be parsed, validated
150150and converted into a :class: `Symfony\\ Component\\ Validator\\ Mapping\\ ClassMetadata `
151- instance. To solve this problem, you can cache the `` ClassMetadata `` information.
151+ instance.
152152
153- You can easily create cachers by creating a class which
154- implements :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Cache\\ CacheInterface `.
153+ To solve this problem, call the :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::setMetadataCache `
154+ method of the Validator builder and pass your own caching class (which must
155+ implement :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Cache\\ CacheInterface `)::
156+
157+ use Symfony\Component\Validator\Validation;
158+
159+ $validator = Validation::createValidatorBuilder()
160+ // ... add loaders
161+ ->setMetadataCache(new SomeImplementCacheInterface());
162+ ->getValidator();
155163
156164.. note ::
157165
@@ -161,17 +169,6 @@ implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface
161169 the Validator still needs to merge all metadata of one class from every
162170 loader when it is requested.
163171
164- Enable the cache calling the
165- :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::setMetadataCache `
166- method of the Validator builder::
167-
168- use Symfony\Component\Validator\Validation;
169-
170- $validator = Validation::createValidatorBuilder()
171- // ... add loaders
172- ->setMetadataCache(new SomeImplementCacheInterface());
173- ->getValidator();
174-
175172Using a Custom MetadataFactory
176173------------------------------
177174
0 commit comments