@@ -293,6 +293,7 @@ Store Scope Blocking Expiring Sharing
293293:ref: `MemcachedStore <lock-store-memcached >` remote no yes no
294294:ref: `MongoDbStore <lock-store-mongodb >` remote no yes no
295295:ref: `PdoStore <lock-store-pdo >` remote no yes no
296+ :ref: `PostgreSqlStore <lock-store-pgsql >` remote yes yes yes
296297:ref: `RedisStore <lock-store-redis >` remote no yes yes
297298:ref: `SemaphoreStore <lock-store-semaphore >` local yes no no
298299:ref: `ZookeeperStore <lock-store-zookeeper >` remote no no no
@@ -340,8 +341,6 @@ support blocking, and expects a TTL to avoid stalled locks::
340341
341342 Memcached does not support TTL lower than 1 second.
342343
343- .. _lock-store-pdo :
344-
345344.. _lock-store-mongodb :
346345
347346MongoDbStore
@@ -403,6 +402,7 @@ MongoDB Connection String:
403402 The ``collection `` querystring parameter is not part of the `MongoDB Connection String `_ definition.
404403 It is used to allow constructing a ``MongoDbStore `` using a `Data Source Name (DSN) `_ without ``$options ``.
405404
405+ .. _lock-store-pdo :
406406
407407PdoStore
408408~~~~~~~~
@@ -427,6 +427,25 @@ You can also create this table explicitly by calling the
427427:method: `Symfony\\ Component\\ Lock\\ Store\\ PdoStore::createTable ` method in
428428your code.
429429
430+ .. _lock-store-pgsql :
431+
432+ PostgreSqlStore
433+ ~~~~~~~~~~~~~~~
434+
435+ The PostgreSqlStore uses `Advisory Locks `_ provided by Postgresql. It requires a
436+ `PDO `_ connection, a `Doctrine DBAL Connection `_, or a
437+ `Data Source Name (DSN) `_. it nativly supports blocking, as weel as sharing
438+ locks.
439+
440+ use Symfony\C omponent\L ock\S tore\P ostgreSqlStore;
441+
442+ // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
443+ $databaseConnectionOrDSN = 'postgresql://myuser:mypassword@localhost:5634/lock';
444+ $store = new PostgreSqlStore($databaseConnectionOrDSN);
445+
446+ In opposite to the `PdoStore `, the `PostgreSqlStore ` does not need a table to stores
447+ locks and does not expires.
448+
430449.. _lock-store-redis :
431450
432451RedisStore
@@ -526,6 +545,7 @@ Remote Stores
526545Remote stores (:ref: `MemcachedStore <lock-store-memcached >`,
527546:ref: `MongoDbStore <lock-store-mongodb >`,
528547:ref: `PdoStore <lock-store-pdo >`,
548+ :ref: `PostgreSqlStore <lock-store-pgsql >`,
529549:ref: `RedisStore <lock-store-redis >` and
530550:ref: `ZookeeperStore <lock-store-zookeeper >`) use a unique token to recognize
531551the true owner of the lock. This token is stored in the
@@ -735,6 +755,20 @@ have synchronized clocks.
735755 To ensure locks don't expire prematurely; the TTLs should be set with
736756 enough extra time to account for any clock drift between nodes.
737757
758+ PostgreSqlStore
759+ ~~~~~~~~~~~~~~~
760+
761+ The PdoStore relies on the `Advisory Locks `_ properties of the Postgresql
762+ database. That means that by using :ref: `PostgreSqlStore <lock-store-pgsql >`
763+ the locks will be automatically released at the end of the session in case the
764+ client cannot unlock for any reason.
765+
766+ If the Postgresql service or the machine hosting it restarts, every lock would
767+ be lost without notifying the running processes.
768+
769+ If the tcp connection is lost, the Postgresql may release locks without
770+ notifying the application.
771+
738772RedisStore
739773~~~~~~~~~~
740774
@@ -839,6 +873,7 @@ are still running.
839873
840874.. _`a maximum of 1024 bytes in length` : https://docs.mongodb.com/manual/reference/limits/#Index-Key-Limit
841875.. _`ACID` : https://en.wikipedia.org/wiki/ACID
876+ .. _`Advisory Locks` : https://www.postgresql.org/docs/current/explicit-locking.html
842877.. _`Data Source Name (DSN)` : https://en.wikipedia.org/wiki/Data_source_name
843878.. _`Doctrine DBAL Connection` : https://github.com/doctrine/dbal/blob/master/src/Connection.php
844879.. _`Expire Data from Collections by Setting TTL` : https://docs.mongodb.com/manual/tutorial/expire-data/
0 commit comments