Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions components/validator/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,21 @@ 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, call the :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache`
To solve this problem, call the :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMappingCache`
method of the Validator builder and pass your own caching class (which must
implement :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`)::
implement the PSR-6 interface :class:`Psr\\Cache\\CacheItemPoolInterface`)::

use Symfony\Component\Validator\Validation;

$validator = Validation::createValidatorBuilder()
// ... add loaders
->setMetadataCache(new SomeImplementCacheInterface());
->setMappingCache(new SomePsr6Cache());
->getValidator();

.. versionadded:: 4.4

Support for PSR-6 compatible mapping caches was introduced in Symfony 4.4.

.. note::

The loaders already use a singleton load mechanism. That means that the
Expand Down