Skip to content

[Lock] Improve the documentation about serializing lock keys #19933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions components/lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ to handle the rest of the job::

use App\Lock\RefreshTaxonomy;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\Lock;

$key = new Key('article.'.$article->getId());
$lock = new Lock(
$lock = $factory->createLockFromKey(
$key,
$this->store,
300, // ttl
false // autoRelease
);
Expand All @@ -124,7 +122,7 @@ to handle the rest of the job::
.. note::

Don't forget to set the ``autoRelease`` argument to ``false`` in the
``Lock`` constructor to avoid releasing the lock when the destructor is
``Lock`` instantiation to avoid releasing the lock when the destructor is
called.

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

The component includes the following built-in store types:

========================================================== ====== ======== ======== =======
Store Scope Blocking Expiring Sharing
========================================================== ====== ======== ======== =======
:ref:`FlockStore <lock-store-flock>` local yes no yes
:ref:`MemcachedStore <lock-store-memcached>` remote no yes no
:ref:`MongoDbStore <lock-store-mongodb>` remote no yes no
:ref:`PdoStore <lock-store-pdo>` remote no yes no
:ref:`DoctrineDbalStore <lock-store-dbal>` remote no yes no
:ref:`PostgreSqlStore <lock-store-pgsql>` remote yes no yes
:ref:`DoctrineDbalPostgreSqlStore <lock-store-dbal-pgsql>` remote yes no yes
:ref:`RedisStore <lock-store-redis>` remote no yes yes
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no
========================================================== ====== ======== ======== =======
========================================================== ====== ======== ======== ======= =============
Store Scope Blocking Expiring Sharing Serialization
========================================================== ====== ======== ======== ======= =============
:ref:`FlockStore <lock-store-flock>` local yes no yes no
:ref:`MemcachedStore <lock-store-memcached>` remote no yes no yes
:ref:`MongoDbStore <lock-store-mongodb>` remote no yes no yes
:ref:`PdoStore <lock-store-pdo>` remote no yes no yes
:ref:`DoctrineDbalStore <lock-store-dbal>` remote no yes no yes
:ref:`PostgreSqlStore <lock-store-pgsql>` remote yes no yes no
:ref:`DoctrineDbalPostgreSqlStore <lock-store-dbal-pgsql>` remote yes no yes no
:ref:`RedisStore <lock-store-redis>` remote no yes yes yes
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no no
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no no
========================================================== ====== ======== ======== ======= =============

.. tip::

Expand Down
Loading