Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68fed1b

Browse files
committed
[Cache] Split PdoAdapter to DoctrineDbalAdapter
1 parent3a3ce9f commit68fed1b

File tree

1 file changed

+57
-9
lines changed

1 file changed

+57
-9
lines changed

‎components/cache/adapters/pdo_doctrine_dbal_adapter.rst‎

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,26 @@
77
PDO & Doctrine DBAL Cache Adapter
88
=================================
99

10-
This adapter stores the cache items in an SQL database. It requires a:phpclass:`PDO`,
11-
`Doctrine DBAL Connection`_, or `Data Source Name (DSN)`_ as its first parameter, and
12-
optionally a namespace, default cache lifetime, and options array as its second,
13-
third, and forth parameters::
10+
The PDO and Doctrine DBAL adapters store the cache items in a table of an SQL database.
11+
12+
..note::
13+
14+
Adapters implement:class:`Symfony\\Component\\Cache\\PruneableInterface`,
15+
allowing for manual:ref:`pruning of expired cache entries<component-cache-cache-pool-prune>` by
16+
calling the ``prune()`` method.
17+
18+
Using:phpclass:`PDO`
19+
---------------------
20+
21+
The:class:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter` requires a:phpclass:`PDO`,
22+
or `Data Source Name (DSN)`_ as its first parameter, and optionally a namespace,
23+
default cache lifetime, and options array as its second, third, and forth parameters::
1424

1525
use Symfony\Component\Cache\Adapter\PdoAdapter;
1626

1727
$cache = new PdoAdapter(
1828

19-
// a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
29+
// a PDO connection or DSN for lazy connecting through PDO
2030
$databaseConnectionOrDSN,
2131

2232
// the string prefixed to the keys of the items stored in this cache
@@ -37,16 +47,54 @@ You can also create this table explicitly by calling the
3747
:method:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter::createTable` method in
3848
your code.
3949

50+
..deprecated::5.4
51+
52+
Using:class:`Symfony\\Component\\Cache\\Adapter\\PdoAdapter` with a
53+
:class:`Doctrine\\DBAL\\Connection` or a DBAL URL is deprecated since Symfony 5.4
54+
and will be removed in Symfony 6.0.
55+
Use:class:`Symfony\\Component\\Cache\\Adapter\\DoctrineDbalAdapter` instead.
56+
4057
..tip::
4158

4259
When passed a `Data Source Name (DSN)`_ string (instead of a database connection
43-
class instance), the connection will be lazy-loaded when needed.
60+
class instance), the connection will be lazy-loaded when needed. DBAL Connection
61+
are lazy-loaded by default; some additional options may be necessary to detect
62+
the database engine and version without opening the connection.
63+
64+
65+
Using Doctrine DBAL
66+
-------------------
67+
68+
The:class:`Symfony\\Component\\Cache\\Adapter\\DoctrineDbalAdapter` requires a
69+
`Doctrine DBAL Connection`_, or `Doctrine DBAL URL`_ as its first parameter, and
70+
optionally a namespace, default cache lifetime, and options array as its second,
71+
third, and forth parameters::
72+
73+
use Symfony\Component\Cache\Adapter\DoctrineDbalAdapter;
74+
75+
$cache = new DoctrineDbalAdapter(
76+
77+
// a Doctrine DBAL connection or DBAL URL
78+
$databaseConnectionOrURL,
79+
80+
// the string prefixed to the keys of the items stored in this cache
81+
$namespace = '',
82+
83+
// the default lifetime (in seconds) for cache items that do not define their
84+
// own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
85+
// until the database table is truncated or its rows are otherwise deleted)
86+
$defaultLifetime = 0,
87+
88+
// an array of options for configuring the database table and connection
89+
$options = []
90+
);
4491

4592
..note::
4693

47-
This adapter implements:class:`Symfony\\Component\\Cache\\PruneableInterface`,
48-
allowing for manual:ref:`pruning of expired cache entries<component-cache-cache-pool-prune>` by
49-
calling its ``prune()`` method.
94+
DBAL Connection are lazy-loaded by default; some additional options may be
95+
necessary to detect the database engine and version without opening the
96+
connection.
5097

5198
.. _`Doctrine DBAL Connection`:https://github.com/doctrine/dbal/blob/master/src/Connection.php
99+
.. _`Doctrine DBAL URL`:https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
52100
.. _`Data Source Name (DSN)`:https://en.wikipedia.org/wiki/Data_source_name

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp