Skip to content

Commit 5e8ea04

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Minor formatting tweaks [Lock] Add new Doctrine DBAL stores
2 parents 9c86ba0 + ce5117c commit 5e8ea04

File tree

1 file changed

+74
-22
lines changed

1 file changed

+74
-22
lines changed

components/lock.rst

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,20 @@ Locks are created and managed in ``Stores``, which are classes that implement
340340

341341
The component includes the following built-in store types:
342342

343-
============================================ ====== ======== ======== =======
344-
Store Scope Blocking Expiring Sharing
345-
============================================ ====== ======== ======== =======
346-
:ref:`FlockStore <lock-store-flock>` local yes no yes
347-
:ref:`MemcachedStore <lock-store-memcached>` remote no yes no
348-
:ref:`MongoDbStore <lock-store-mongodb>` remote no yes no
349-
:ref:`PdoStore <lock-store-pdo>` remote no yes no
350-
:ref:`PostgreSqlStore <lock-store-pgsql>` remote yes no yes
351-
:ref:`RedisStore <lock-store-redis>` remote no yes yes
352-
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no
353-
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no
354-
============================================ ====== ======== ======== =======
343+
========================================================= ====== ======== ======== =======
344+
Store Scope Blocking Expiring Sharing
345+
========================================================= ====== ======== ======== =======
346+
:ref:`FlockStore <lock-store-flock>` local yes no yes
347+
:ref:`MemcachedStore <lock-store-memcached>` remote no yes no
348+
:ref:`MongoDbStore <lock-store-mongodb>` remote no yes no
349+
:ref:`PdoStore <lock-store-pdo>` remote no yes no
350+
:ref:`DoctrineDbalStore <lock-store-dbal>` remote no yes no
351+
:ref:`PostgreSqlStore <lock-store-pgsql>` remote yes no yes
352+
:ref:`DoctrineDbalPostgreSqlStore <lock-store-dbal-pgsql>` remote yes no yes
353+
:ref:`RedisStore <lock-store-redis>` remote no yes yes
354+
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no
355+
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no
356+
========================================================= ====== ======== ======== =======
355357

356358
.. _lock-store-flock:
357359

@@ -457,13 +459,13 @@ MongoDB Connection String:
457459
PdoStore
458460
~~~~~~~~
459461

460-
The PdoStore saves locks in an SQL database. It requires a `PDO`_ connection, a
461-
`Doctrine DBAL Connection`_, or a `Data Source Name (DSN)`_. This store does not
462-
support blocking, and expects a TTL to avoid stalled locks::
462+
The PdoStore saves locks in an SQL database. It is identical to DoctrineDbalStore
463+
but requires a `PDO`_ connection or a `Data Source Name (DSN)`_. This store does
464+
not support blocking, and expects a TTL to avoid stalled locks::
463465

464466
use Symfony\Component\Lock\Store\PdoStore;
465467

466-
// a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
468+
// a PDO or DSN for lazy connecting through PDO
467469
$databaseConnectionOrDSN = 'mysql:host=127.0.0.1;dbname=app';
468470
$store = new PdoStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
469471

@@ -477,25 +479,74 @@ You can also create this table explicitly by calling the
477479
:method:`Symfony\\Component\\Lock\\Store\\PdoStore::createTable` method in
478480
your code.
479481

482+
.. deprecated:: 5.4
483+
484+
Using ``PdoStore`` with Doctrine DBAL is deprecated in Symfony 5.4.
485+
Use ``DoctrineDbalStore`` instead.
486+
487+
.. _lock-store-dbal:
488+
489+
DoctrineDbalStore
490+
~~~~~~~~~~~~~~~~~
491+
492+
The DoctrineDbalStore saves locks in an SQL database. It is identical to PdoStore
493+
but requires a `Doctrine DBAL Connection`_, or a `Doctrine DBAL URL`_. This store
494+
does not support blocking, and expects a TTL to avoid stalled locks::
495+
496+
use Symfony\Component\Lock\Store\PdoStore;
497+
498+
// a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
499+
$connectionOrURL = 'mysql://myuser:mypassword@127.0.0.1/app';
500+
$store = new PdoStore($connectionOrURL);
501+
502+
.. note::
503+
504+
This store does not support TTL lower than 1 second.
505+
506+
The table where values are stored is created automatically on the first call to
507+
the :method:`Symfony\\Component\\Lock\\Store\\DoctrineDbalStore::save` method.
508+
You can also add this table to your schema by calling
509+
:method:`Symfony\\Component\\Lock\\Store\\DoctrineDbalStore::configureSchema` method
510+
in your code or create this table explicitly by calling the
511+
:method:`Symfony\\Component\\Lock\\Store\\DoctrineDbalStore::createTable` method.
512+
480513
.. _lock-store-pgsql:
481514

482515
PostgreSqlStore
483516
~~~~~~~~~~~~~~~
484517

485-
The PostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL. It requires a
486-
`PDO`_ connection, a `Doctrine DBAL Connection`_, or a
487-
`Data Source Name (DSN)`_. It supports native blocking, as well as sharing
518+
The PostgreSqlStore and DoctrineDbalPostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL.
519+
It is identical to DoctrineDbalPostgreSqlStore but requires `PDO`_ connection or
520+
a `Data Source Name (DSN)`_. It supports native blocking, as well as sharing
488521
locks::
489522

490523
use Symfony\Component\Lock\Store\PostgreSqlStore;
491524

492-
// a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
493-
$databaseConnectionOrDSN = 'postgresql://myuser:mypassword@localhost:5634/lock';
494-
$store = new PostgreSqlStore($databaseConnectionOrDSN);
525+
// a PDO instance or DSN for lazy connecting through PDO
526+
$databaseConnectionOrDSN = 'pgsql:host=localhost;port=5634;dbname=lock';
527+
$store = new PostgreSqlStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
495528

496529
In opposite to the ``PdoStore``, the ``PostgreSqlStore`` does not need a table to
497530
store locks and it does not expire.
498531

532+
.. _lock-store-dbal-pgsql:
533+
534+
DoctrineDbalPostgreSqlStore
535+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
536+
537+
The DoctrineDbalPostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL.
538+
It is identical to PostgreSqlStore but requires a `Doctrine DBAL Connection`_ or
539+
a `Doctrine DBAL URL`_. It supports native blocking, as well as sharing locks::
540+
541+
use Symfony\Component\Lock\Store\PostgreSqlStore;
542+
543+
// a PDO instance or DSN for lazy connecting through PDO
544+
$databaseConnectionOrDSN = 'pgsql:host=localhost;port=5634;dbname=lock';
545+
$store = new PostgreSqlStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
546+
547+
In opposite to the ``DoctrineDbalStore``, the ``DoctrineDbalPostgreSqlStore`` does not need a table to
548+
store locks and does not expire.
549+
499550
.. _lock-store-redis:
500551

501552
RedisStore
@@ -922,6 +973,7 @@ are still running.
922973
.. _`Advisory Locks`: https://www.postgresql.org/docs/current/explicit-locking.html
923974
.. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name
924975
.. _`Doctrine DBAL Connection`: https://github.com/doctrine/dbal/blob/master/src/Connection.php
976+
.. _`Doctrine DBAL URL`: https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
925977
.. _`Expire Data from Collections by Setting TTL`: https://docs.mongodb.com/manual/tutorial/expire-data/
926978
.. _`locks`: https://en.wikipedia.org/wiki/Lock_(computer_science)
927979
.. _`MongoDB Connection String`: https://docs.mongodb.com/manual/reference/connection-string/

0 commit comments

Comments
 (0)