Skip to content
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

Document PSR-6 caching #4652

Merged
merged 1 commit into from
Jun 7, 2021
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
13 changes: 8 additions & 5 deletions docs/en/reference/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ To use the result cache, there are three mandatory steps:
Configuring the result cache
----------------------------

Any instance of ``Doctrine\Common\Cache\Cache`` can be used as a result
Any instance of ``Psr\Cache\CacheItemPoolInterface`` can be used as a result
cache and can be set on the configuration object (optionally it can also
be passed at query time):

::

<?php
$cache = new \Doctrine\Common\Cache\ArrayCache();
$cache = new \Symfony\Component\Cache\Adapter\ArrayAdapter();
$config = $conn->getConfiguration();
$config->setResultCacheImpl($cache);
$config->setResultCache($cache);

Note that this documentation uses Symfony Cache in all examples. Any other cache implementation
that follows the PSR-6 standard can be used instead.

Providing a cache profile
-------------------------
Expand All @@ -41,14 +44,14 @@ optional argument, whereas it is required when calling the latter:
$stmt = $conn->executeCacheQuery($query, $params, $types, new QueryCacheProfile(0, "some key"));

As stated before, it is also possible to pass in a
``Doctrine\Common\Cache\Cache`` instance into the constructor of
``Psr\Cache\CacheItemPoolInterface`` instance into the constructor of
``Doctrine\DBAL\Cache\QueryCacheProfile`` in which case it overrides the
default cache instance:

::

<?php
$cache = new \Doctrine\Common\Cache\FilesystemCache(__DIR__);
$cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter();
new QueryCacheProfile(0, "some key", $cache);

Reading the entire result set
Expand Down