@@ -148,10 +148,18 @@ Caching
148
148
Using many loaders to load metadata from different places is convenient, but it
149
149
can slow down your application because each file needs to be parsed, validated
150
150
and converted into a :class: `Symfony\\ Component\\ Validator\\ Mapping\\ ClassMetadata `
151
- instance. To solve this problem, you can cache the `` ClassMetadata `` information.
151
+ instance.
152
152
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();
155
163
156
164
.. note ::
157
165
@@ -161,17 +169,6 @@ implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface
161
169
the Validator still needs to merge all metadata of one class from every
162
170
loader when it is requested.
163
171
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
-
175
172
Using a Custom MetadataFactory
176
173
------------------------------
177
174
0 commit comments