Skip to content

Commit 55859c6

Browse files
committed
minor #19933 [Lock] Improve the documentation about serializing lock keys (stof)
This PR was merged into the 5.4 branch. Discussion ---------- [Lock] Improve the documentation about serializing lock keys - use the LockFactory, which is consistent with other examples and is the recommended usage in the fullstack framework rather than injecting the Store to create a Lock directly - update the lock store table to document which stores are compatible with serialization, as the section about serialization is linking to this table for compatibility info but it was not included Commits ------- 3444ffb Improve the documentation about serializing lock keys
2 parents bf82fc3 + 3444ffb commit 55859c6

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

components/lock.rst

+16-18
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,10 @@ to handle the rest of the job::
108108

109109
use App\Lock\RefreshTaxonomy;
110110
use Symfony\Component\Lock\Key;
111-
use Symfony\Component\Lock\Lock;
112111

113112
$key = new Key('article.'.$article->getId());
114-
$lock = new Lock(
113+
$lock = $factory->createLockFromKey(
115114
$key,
116-
$this->store,
117115
300, // ttl
118116
false // autoRelease
119117
);
@@ -124,7 +122,7 @@ to handle the rest of the job::
124122
.. note::
125123

126124
Don't forget to set the ``autoRelease`` argument to ``false`` in the
127-
``Lock`` constructor to avoid releasing the lock when the destructor is
125+
``Lock`` instantiation to avoid releasing the lock when the destructor is
128126
called.
129127

130128
Not all stores are compatible with serialization and cross-process locking: for
@@ -402,20 +400,20 @@ Locks are created and managed in ``Stores``, which are classes that implement
402400

403401
The component includes the following built-in store types:
404402

405-
========================================================== ====== ======== ======== =======
406-
Store Scope Blocking Expiring Sharing
407-
========================================================== ====== ======== ======== =======
408-
:ref:`FlockStore <lock-store-flock>` local yes no yes
409-
:ref:`MemcachedStore <lock-store-memcached>` remote no yes no
410-
:ref:`MongoDbStore <lock-store-mongodb>` remote no yes no
411-
:ref:`PdoStore <lock-store-pdo>` remote no yes no
412-
:ref:`DoctrineDbalStore <lock-store-dbal>` remote no yes no
413-
:ref:`PostgreSqlStore <lock-store-pgsql>` remote yes no yes
414-
:ref:`DoctrineDbalPostgreSqlStore <lock-store-dbal-pgsql>` remote yes no yes
415-
:ref:`RedisStore <lock-store-redis>` remote no yes yes
416-
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no
417-
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no
418-
========================================================== ====== ======== ======== =======
403+
========================================================== ====== ======== ======== ======= =============
404+
Store Scope Blocking Expiring Sharing Serialization
405+
========================================================== ====== ======== ======== ======= =============
406+
:ref:`FlockStore <lock-store-flock>` local yes no yes no
407+
:ref:`MemcachedStore <lock-store-memcached>` remote no yes no yes
408+
:ref:`MongoDbStore <lock-store-mongodb>` remote no yes no yes
409+
:ref:`PdoStore <lock-store-pdo>` remote no yes no yes
410+
:ref:`DoctrineDbalStore <lock-store-dbal>` remote no yes no yes
411+
:ref:`PostgreSqlStore <lock-store-pgsql>` remote yes no yes no
412+
:ref:`DoctrineDbalPostgreSqlStore <lock-store-dbal-pgsql>` remote yes no yes no
413+
:ref:`RedisStore <lock-store-redis>` remote no yes yes yes
414+
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no no
415+
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no no
416+
========================================================== ====== ======== ======== ======= =============
419417

420418
.. tip::
421419

0 commit comments

Comments
 (0)