Skip to content

Update doc. Remove class ApcCache from doc #7627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2017
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
28 changes: 11 additions & 17 deletions components/validator/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +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.

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
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::

Expand All @@ -163,18 +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;
use Symfony\Component\Validator\Mapping\Cache\ApcCache;

$validator = Validation::createValidatorBuilder()
// ... add loaders
->setMetadataCache(new ApcCache('some_apc_prefix'));
->getValidator();

Using a Custom MetadataFactory
------------------------------

Expand Down