@@ -350,18 +350,20 @@ Locks are created and managed in ``Stores``, which are classes that implement
350
350
351
351
The component includes the following built-in store types:
352
352
353
- ============================================ ====== ======== ======== =======
354
- Store Scope Blocking Expiring Sharing
355
- ============================================ ====== ======== ======== =======
356
- :ref: `FlockStore <lock-store-flock >` local yes no yes
357
- :ref: `MemcachedStore <lock-store-memcached >` remote no yes no
358
- :ref: `MongoDbStore <lock-store-mongodb >` remote no yes no
359
- :ref: `PdoStore <lock-store-pdo >` remote no yes no
360
- :ref: `PostgreSqlStore <lock-store-pgsql >` remote yes no yes
361
- :ref: `RedisStore <lock-store-redis >` remote no yes yes
362
- :ref: `SemaphoreStore <lock-store-semaphore >` local yes no no
363
- :ref: `ZookeeperStore <lock-store-zookeeper >` remote no no no
364
- ============================================ ====== ======== ======== =======
353
+ ========================================================= ====== ======== ======== =======
354
+ Store Scope Blocking Expiring Sharing
355
+ ========================================================= ====== ======== ======== =======
356
+ :ref: `FlockStore <lock-store-flock >` local yes no yes
357
+ :ref: `MemcachedStore <lock-store-memcached >` remote no yes no
358
+ :ref: `MongoDbStore <lock-store-mongodb >` remote no yes no
359
+ :ref: `PdoStore <lock-store-pdo >` remote no yes no
360
+ :ref: `DoctrineDbalStore <lock-store-dbal >` remote no yes no
361
+ :ref: `PostgreSqlStore <lock-store-pgsql >` remote yes no yes
362
+ :ref: `DoctrineDbalPostgreSqlStore <lock-store-dbal-pgsql >` remote yes no yes
363
+ :ref: `RedisStore <lock-store-redis >` remote no yes yes
364
+ :ref: `SemaphoreStore <lock-store-semaphore >` local yes no no
365
+ :ref: `ZookeeperStore <lock-store-zookeeper >` remote no no no
366
+ ========================================================= ====== ======== ======== =======
365
367
366
368
.. _lock-store-flock :
367
369
@@ -471,13 +473,13 @@ MongoDB Connection String:
471
473
PdoStore
472
474
~~~~~~~~
473
475
474
- The PdoStore saves locks in an SQL database. It requires a ` PDO `_ connection, a
475
- ` Doctrine DBAL Connection `_, or a `Data Source Name (DSN) `_. This store does not
476
+ The PdoStore saves locks in an SQL database. It is identical to DoctrineDbalStore but requires
477
+ a ` PDO `_ connection or a `Data Source Name (DSN) `_. This store does not
476
478
support blocking, and expects a TTL to avoid stalled locks::
477
479
478
480
use Symfony\Component\Lock\Store\PdoStore;
479
481
480
- // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
482
+ // a PDO or DSN for lazy connecting through PDO
481
483
$databaseConnectionOrDSN = 'mysql:host=127.0.0.1;dbname=app';
482
484
$store = new PdoStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
483
485
@@ -491,21 +493,56 @@ You can also create this table explicitly by calling the
491
493
:method: `Symfony\\ Component\\ Lock\\ Store\\ PdoStore::createTable ` method in
492
494
your code.
493
495
496
+ .. deprecated :: 5.4
497
+
498
+ Using ``PdoStore `` with Doctrine DBAL is deprecated in Symfony 5.4. Use ``DoctrineDbalStore `` instead.
499
+
500
+ .. _lock-store-dbal :
501
+
502
+ DoctrineDbalStore
503
+ ~~~~~~~~~~~~~~~~~
504
+
505
+ The DoctrineDbalStore saves locks in an SQL database. It is identical to PdoStore but requires a
506
+ `Doctrine DBAL Connection `_, or a `Doctrine DBAL URL `_. This store does not
507
+ support blocking, and expects a TTL to avoid stalled locks::
508
+
509
+ use Symfony\Component\Lock\Store\PdoStore;
510
+
511
+ // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
512
+ $connectionOrURL = 'mysql://myuser:mypassword@127.0.0.1/app';
513
+ $store = new PdoStore($connectionOrURL);
514
+
515
+ .. note ::
516
+
517
+ This store does not support TTL lower than 1 second.
518
+
519
+ The table where values are stored is created automatically on the first call to
520
+ the :method: `Symfony\\ Component\\ Lock\\ Store\\ DoctrineDbalStore::save ` method.
521
+ You can also add this table to your schema by calling
522
+ :method: `Symfony\\ Component\\ Lock\\ Store\\ DoctrineDbalStore::configureSchema ` method
523
+ in your code or create this table explicitly by calling the
524
+ :method: `Symfony\\ Component\\ Lock\\ Store\\ DoctrineDbalStore::createTable ` method.
525
+
526
+ .. versionadded :: 5.4
527
+
528
+ The ``DoctrineDbalStore `` was introduced in Symfony 5.4 to replace ``PdoStore `` when
529
+ used with Doctrine DBAL.
530
+
494
531
.. _lock-store-pgsql :
495
532
496
533
PostgreSqlStore
497
534
~~~~~~~~~~~~~~~
498
535
499
- The PostgreSqlStore uses `Advisory Locks `_ provided by PostgreSQL. It requires a
500
- ` PDO `_ connection, a ` Doctrine DBAL Connection `_, or a
501
- `Data Source Name (DSN) `_. It supports native blocking, as well as sharing
536
+ The PostgreSqlStore and DoctrineDbalPostgreSqlStore uses `Advisory Locks `_ provided by PostgreSQL.
537
+ It is identical to DoctrineDbalPostgreSqlStore but requires ` PDO `_ connection or
538
+ a `Data Source Name (DSN) `_. It supports native blocking, as well as sharing
502
539
locks::
503
540
504
541
use Symfony\Component\Lock\Store\PostgreSqlStore;
505
542
506
- // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
507
- $databaseConnectionOrDSN = 'postgresql://myuser:mypassword@ localhost: 5634/ lock';
508
- $store = new PostgreSqlStore($databaseConnectionOrDSN);
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'] );
509
546
510
547
In opposite to the ``PdoStore ``, the ``PostgreSqlStore `` does not need a table to
511
548
store locks and it does not expire.
@@ -514,6 +551,34 @@ store locks and it does not expire.
514
551
515
552
The ``PostgreSqlStore `` was introduced in Symfony 5.2.
516
553
554
+ .. deprecated :: 5.4
555
+
556
+ Using ``PostgreSqlStore `` with Doctrine DBAL is deprecated in Symfony 5.4. Use ``DoctrineDbalPostgreSqlStore `` instead.
557
+
558
+ .. _lock-store-dbal-pgsql :
559
+
560
+ DoctrineDbalPostgreSqlStore
561
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
562
+
563
+ The DoctrineDbalPostgreSqlStore uses `Advisory Locks `_ provided by PostgreSQL. It is identical to PostgreSqlStore
564
+ but requires a `Doctrine DBAL Connection `_ or a `Doctrine DBAL URL `_.
565
+ It supports native blocking, as well as sharing
566
+ locks::
567
+
568
+ use Symfony\Component\Lock\Store\PostgreSqlStore;
569
+
570
+ // a PDO instance or DSN for lazy connecting through PDO
571
+ $databaseConnectionOrDSN = 'pgsql:host=localhost;port=5634;dbname=lock';
572
+ $store = new PostgreSqlStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
573
+
574
+ In opposite to the ``DoctrineDbalStore ``, the ``DoctrineDbalPostgreSqlStore `` does not need a table to
575
+ store locks and does not expire.
576
+
577
+ .. versionadded :: 5.4
578
+
579
+ The ``DoctrineDbalPostgreSqlStore `` was introduced in Symfony 5.4 to replace ``PostgreSqlStore `` when
580
+ used with Doctrine DBAL.
581
+
517
582
.. _lock-store-redis :
518
583
519
584
RedisStore
@@ -940,6 +1005,7 @@ are still running.
940
1005
.. _`Advisory Locks` : https://www.postgresql.org/docs/current/explicit-locking.html
941
1006
.. _`Data Source Name (DSN)` : https://en.wikipedia.org/wiki/Data_source_name
942
1007
.. _`Doctrine DBAL Connection` : https://github.com/doctrine/dbal/blob/master/src/Connection.php
1008
+ .. _`Doctrine DBAL URL` : https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
943
1009
.. _`Expire Data from Collections by Setting TTL` : https://docs.mongodb.com/manual/tutorial/expire-data/
944
1010
.. _`locks` : https://en.wikipedia.org/wiki/Lock_(computer_science)
945
1011
.. _`MongoDB Connection String` : https://docs.mongodb.com/manual/reference/connection-string/
0 commit comments