Skip to content

[Lock] Add DynamoDbStore #20944

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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
from
Open
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions components/lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
: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
:ref:`DynamoDbStore <lock-store-dynamodb>` remote no yes no yes
========================================================== ====== ======== ======== ======= =============

.. tip::
Expand Down Expand Up @@ -698,6 +699,32 @@
Zookeeper does not require a TTL as the nodes used for locking are ephemeral
and die when the PHP process is terminated.

.. _lock-store-dynamodb:

DynamoDbStore
~~~~~~~~~~~~~

The DynamoDbStore saves locks on a Amazon DynamoDB table. Install it by running:

.. code-block:: terminal

$ composer require symfony/amazon-dynamodb-lock

It requires a `DynamoDbClient`_ instance or a `Data Source Name (DSN)`_.
This store does not support blocking, and expects a TTL to avoid stalled locks::

use Symfony\Component\Lock\Bridge\DynamoDb\Store\DynamoDbStore;

Check failure on line 716 in components/lock.rst

View workflow job for this annotation

GitHub Actions / Code Blocks

[Missing class] Class, interface or trait with name "Symfony\Component\Lock\Bridge\DynamoDb\Store\DynamoDbStore" does not exist

// a DynamoDbClient instance or DSN
$dynamoDbClientOrDSN = 'dynamodb://default/lock';
$store = new DynamoDbStore($dynamoDbClientOrDSN);

The table where values are stored is created automatically on the first call to
the :method:`Symfony\\Component\\Lock\\Bridge\\DynamoDb\\DynamoDbStore::save` method.
You can also create this table explicitly by calling the
:method:`Symfony\\Component\\Lock\\Bridge\\DynamoDb\\DynamoDbStore::createTable` method in
your code.

Reliability
-----------

Expand Down Expand Up @@ -1049,3 +1076,4 @@
.. _`readers-writer lock`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock
.. _`priority policy`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Priority_policies
.. _`PCNTL`: https://www.php.net/manual/book.pcntl.php
.. _`DynamoDbClient`: https://async-aws.com/clients/dynamodb.html
4 changes: 4 additions & 0 deletions lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ this behavior by using the ``lock`` key like:
lock: 'sqlsrv:server=127.0.0.1;Database=app'
lock: 'oci:host=127.0.0.1;dbname=app'
lock: 'mongodb://127.0.0.1/app?collection=lock'
lock: 'dynamodb://127.0.0.1/lock'
lock: '%env(LOCK_DSN)%'
# using an existing service
lock: 'snc_redis.default'
Expand Down Expand Up @@ -119,6 +120,8 @@ this behavior by using the ``lock`` key like:

<framework:resource>mongodb://127.0.0.1/app?collection=lock</framework:resource>

<framework:resource>dynamodb://127.0.0.1/lock</framework:resource>

<framework:resource>%env(LOCK_DSN)%</framework:resource>

<!-- using an existing service -->
Expand Down Expand Up @@ -157,6 +160,7 @@ this behavior by using the ``lock`` key like:
->resource('default', ['sqlsrv:server=127.0.0.1;Database=app'])
->resource('default', ['oci:host=127.0.0.1;dbname=app'])
->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
->resource('default', ['dynamodb://127.0.0.1/lock'])
->resource('default', [env('LOCK_DSN')])
// using an existing service
->resource('default', ['snc_redis.default'])
Expand Down
Loading