@@ -340,18 +340,20 @@ Locks are created and managed in ``Stores``, which are classes that implement
340
340
341
341
The component includes the following built-in store types:
342
342
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
+ ========================================================= ====== ======== ======== =======
355
357
356
358
.. _lock-store-flock :
357
359
@@ -457,13 +459,13 @@ MongoDB Connection String:
457
459
PdoStore
458
460
~~~~~~~~
459
461
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::
463
465
464
466
use Symfony\Component\Lock\Store\PdoStore;
465
467
466
- // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
468
+ // a PDO or DSN for lazy connecting through PDO
467
469
$databaseConnectionOrDSN = 'mysql:host=127.0.0.1;dbname=app';
468
470
$store = new PdoStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
469
471
@@ -477,25 +479,74 @@ You can also create this table explicitly by calling the
477
479
:method: `Symfony\\ Component\\ Lock\\ Store\\ PdoStore::createTable ` method in
478
480
your code.
479
481
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
+
480
513
.. _lock-store-pgsql :
481
514
482
515
PostgreSqlStore
483
516
~~~~~~~~~~~~~~~
484
517
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
488
521
locks::
489
522
490
523
use Symfony\Component\Lock\Store\PostgreSqlStore;
491
524
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'] );
495
528
496
529
In opposite to the ``PdoStore ``, the ``PostgreSqlStore `` does not need a table to
497
530
store locks and it does not expire.
498
531
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
+
499
550
.. _lock-store-redis :
500
551
501
552
RedisStore
@@ -922,6 +973,7 @@ are still running.
922
973
.. _`Advisory Locks` : https://www.postgresql.org/docs/current/explicit-locking.html
923
974
.. _`Data Source Name (DSN)` : https://en.wikipedia.org/wiki/Data_source_name
924
975
.. _`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
925
977
.. _`Expire Data from Collections by Setting TTL` : https://docs.mongodb.com/manual/tutorial/expire-data/
926
978
.. _`locks` : https://en.wikipedia.org/wiki/Lock_(computer_science)
927
979
.. _`MongoDB Connection String` : https://docs.mongodb.com/manual/reference/connection-string/
0 commit comments