8000 Merge branch '5.4' into 6.3 · symfony/symfony-docs@80cb7b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 80cb7b2

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: Typo in cache dir env var explanation [Cache] Fix doc for Doctrine DBAL adapter
2 parents be8ff58 + e5376be commit 80cb7b2

File tree

7 files changed

+117
-96
lines changed

7 files changed

+117
-96
lines changed

cache.rst

Lines changed: 12 additions & 4 deletions
< 8000 td data-grid-cell-id="diff-8d0ff073208b4ebfbd064d55c3957dda3d98d8e836adc48080072394208aabd4-156-162-2" data-line-anchor="diff-8d0ff073208b4ebfbd064d55c3957dda3d98d8e836adc48080072394208aabd4R162" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionLine-bgColor, var(--diffBlob-addition-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">+
default_pdo_provider="pgsql:host=localhost"
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ The Cache component comes with a series of adapters pre-configured:
101101

102102
* :doc:`cache.adapter.apcu </components/cache/adapters/apcu_adapter>`
103103
* :doc:`cache.adapter.array </components/cache/adapters/array_cache_adapter>`
104+
* :doc:`cache.adapter.doctrine </components/cache/adapters/doctrine_adapter>` (deprecated)
105+
* :doc:`cache.adapter.doctrine_dbal </components/cache/adapters/doctrine_dbal_adapter>`
104106
* :doc:`cache.adapter.filesystem </components/cache/adapters/filesystem_adapter>`
105107
* :doc:`cache.adapter.memcached </components/cache/adapters/memcached_adapter>`
106-
* :doc:`cache.adapter.pdo </components/cache/adapters/pdo_doctrine_dbal_adapter>`
108+
* :doc:`cache.adapter.pdo </components/cache/adapters/pdo_adapter>`
107109
* :doc:`cache.adapter.psr6 </components/cache/adapters/proxy_adapter>`
108110
* :doc:`cache.adapter.redis </components/cache/adapters/redis_adapter>`
109111
* :ref:`cache.adapter.redis_tag_aware <redis-tag-aware-adapter>` (Redis adapter optimized to work with tags)
@@ -120,14 +122,16 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
120122
cache:
121123
directory: '%kernel.cache_dir%/pools' # Only used with cache.adapter.filesystem
122124
125+
# service: cache.doctrine_dbal
126+
default_doctrine_dbal_provider: 'doctrine.dbal.default_connection'
123127
# service: cache.psr6
124128
default_psr6_provider: 'app.my_psr6_service'
125129
# service: cache.redis
126130
default_redis_provider: 'redis://localhost'
127131
# service: cache.memcached
128132
default_memcached_provider: 'memcached://localhost'
129133
# service: cache.pdo
130-
default_pdo_provider: 'doctrine.dbal.default_connection'
134+
default_pdo_provider: 'pgsql:host=localhost'
131135
132136
.. code-block:: xml
133137
@@ -143,17 +147,19 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
143147
>
144148
<framework:config>
145149
<!--
150+
default_doctrine_dbal_provider: Service: cache.doctrine_dbal
146151
default_psr6_provider: Service: cache.psr6
147152
default_redis_provider: Service: cache.redis
148153
default_memcached_provider: Service: cache.memcached
149154
default_pdo_provider: Service: cache.pdo
150155
-->
151156
<!-- "directory" attribute is only used with cache.adapter.filesystem -->
152157
<framework:cache directory="%kernel.cache_dir%/pools"
158+
default_doctrine_dbal_provider="doctrine.dbal.default_connection"
153159
default_psr6_provider="app.my_psr6_service"
154160
default_redis_provider="redis://localhost"
155161
default_memcached_provider="memcached://localhost"
156-
default_pdo_provider="doctrine.dbal.default_connection"
162
157163
/>
158164
</framework:config>
159165
</container>
@@ -167,14 +173,16 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
167173
$framework->cache()
168174
// Only used with cache.adapter.filesystem
169175
->directory('%kernel.cache_dir%/pools')
176+
// Service: cache.doctrine_dbal
177+
->defaultDoctrineDbalProvider('doctrine.dbal.default_connection')
170178
// Service: cache.psr6
171179
->defaultPsr6Provider('app.my_psr6_service')
172180
// Service: cache.redis
173181
->defaultRedisProvider('redis://localhost')
174182
// Service: cache.memcached
175183
->defaultMemcachedProvider('memcached://localhost')
176184
// Service: cache.pdo
177-
->defaultPdoProvider('doctrine.dbal.default_connection')
185+
->defaultPdoProvider('pgsql:host=localhost')
178186
;
179187
};
180188
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. _doctrine-dbal-adapter:
2+
3+
Doctrine DBAL Cache Adapter
4+
===========================
5+
6+
The Doctrine DBAL adapters store the cache items in a table of an SQL database.
7+
8+
.. note::
9+
10+
This adapter implements :class:`Symfony\\Component\\Cache\\PruneableInterface`,
11+
allowing for manual :ref:`pruning of expired cache entries <component-cache-cache-pool-prune>`
12+
by calling the ``prune()`` method.
13+
14+
The :class:`Symfony\\Component\\Cache\\Adapter\\DoctrineDbalAdapter` requires a
15+
`Doctrine DBAL Connection`_, or `Doctrine DBAL URL`_ as its first parameter.
16+
You can pass a namespace, default cache lifetime, and options array as the other
17+
optional arguments::
18+
19+
use Symfony\Component\Cache\Adapter\DoctrineDbalAdapter;
20+
21+
$cache = new DoctrineDbalAdapter(
22+
23+
// a Doctrine DBAL connection or DBAL URL
24+
$databaseConnectionOrURL,
25+
26+
// the string prefixed to the keys of the items stored in this cache
27+
$namespace = '',
28+
29+
// the default lifetime (in seconds) for cache items that do not define their
30+
// own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
31+
// until the database table is truncated or its rows are otherwise deleted)
32+
$defaultLifetime = 0,
33+
34+
// an array of options for configuring the database table and connection
35+
$options = []
36+
);
37+
38+
.. note::
39+
40+
DBAL Connection are lazy-loaded by default; some additional options may be
41+
necessary to detect the database engine and version without opening the
42+
connection.
43+
44+
.. _`Doctrine DBAL Connection`: https://github.com/doctrine/dbal/blob/master/src/Connection.php
45+
.. _`Doctrine DBAL URL`: https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url

components/cache/adapters/filesystem_adapter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ and cache root path as constructor parameters::
4141
choices. If throughput is paramount, the in-memory adapters
4242
(:ref:`Apcu <apcu-adapter>`, :ref:`Memcached <memcached-adapter>`, and
4343
:ref:`Redis <redis-adapter>`) or the database adapters
44-
(:ref:`PDO <pdo-doctrine-adapter>`) are recommended.
44+
(:ref:`Doctrine DBAL <doctrine-dbal-adapter>`, :ref:`PDO <pdo-adapter>`) are recommended.
4545

4646
.. note::
4747

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.. _pdo-adapter:
2+
3+
PDO Cache Adapter
4+
=================
5+
6+
The PDO adapters store the cache items in a table of an SQL database.
7+
8+
.. note::
9+
10+
This adapter implements :class:`Symfony\\Component\\Cache\\PruneableInterface`,
11+
allowing for manual :ref:`pruning of expired cache entries <component-cache-cache-pool-prune>`
12+
by calling the ``prune()`` method.
13+
14+
The :class:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter` requires a :phpclass:`PDO`,
15+
or `DSN`_ as its first parameter. You can pass a namespace,
16+
default cache lifetime, and options array as the other optional arguments::
17+
18+
use Symfony\Component\Cache\Adapter\PdoAdapter;
19+
20+
$cache = new PdoAdapter(
21+
22+
// a PDO connection or DSN for lazy connecting through PDO
23+
$databaseConnectionOrDSN,
24+
25+
// the string prefixed to the keys of the items stored in this cache
26+
$namespace = '',
27+
28+
// the default lifetime (in seconds) for cache items that do not define their
29+
// own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
30+
// until the database table is truncated or its rows are otherwise deleted)
31+
$defaultLifetime = 0,
32+
33+
// an array of options for configuring the database table and connection
34+
$options = []
35+
);
36+
37+
The table where values are stored is created automatically on the first call to
38+
the :method:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter::save` method.
39+
You can also create this table explicitly by calling the
40+
:method:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter::createTable` method in
41+
your code.
42+
43+
.. deprecated:: 5.4
44+
45+
Using :class:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter` with a
46+
:class:`Doctrine\\DBAL\\Connection` or a DBAL URL is deprecated since Symfony 5.4
47+
and will be removed in Symfony 6.0.
48+
Use :class:`Symfony\\Component\\Cache\\Adapter\\DoctrineDbalAdapter` instead.
49+
50+
.. tip::
51+
52+
When passed a `Data Source Name (DSN)`_ string (instead of a database connection
53+
class instance), the connection will be lazy-loaded when needed.
54+
55+
.. _`DSN`: https://php.net/manual/pdo.drivers.php

components/cache/adapters/pdo_doctrine_dbal_adapter.rst

Lines changed: 0 additions & 88 deletions
This file was deleted.

components/cache/cache_pools.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ This shortcoming has been solved through the introduction of
203203
:class:`Symfony\\Component\\Cache\\PruneableInterface`, which defines the abstract method
204204
:method:`Symfony\\Component\\Cache\\PruneableInterface::prune`. The
205205
:ref:`ChainAdapter <component-cache-chain-adapter>`,
206+
:ref:`DoctrineDbalAdapter <doctrine-dbal-adapter>`, and
206207
:ref:`FilesystemAdapter <component-cache-filesystem-adapter>`,
207-
:ref:`PdoAdapter <pdo-doctrine-adapter>`, and
208+
:ref:`PdoAdapter <pdo-adapter>`, and
208209
:ref:`PhpFilesAdapter <component-cache-files-adapter>` all implement this new interface,
209210
allowing manual removal of stale cache items::
210211

configuration/override_dir_structure.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ In this code, ``$this->environment`` is the current environment (i.e. ``dev``).
109109
In this case you have changed the location of the cache directory to
110110
``var/{environment}/cache/``.
111111

112-
You can also change the cache directory defining an environment variable named
113-
``APP_CACHE_DIR`` whose value is the full path of the cache folder.
112+
You can also change the cache directory by defining an environment variable
113+
named ``APP_CACHE_DIR`` whose value is the full path of the cache folder.
114114

115115
.. caution::
116116

0 commit comments

Comments
 (0)
0