Skip to content

Commit 0b15645

Browse files
committed
[Lock] Add DynamoDbStore
1 parent 2aa1a43 commit 0b15645

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

components/lock.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ Store Scope Blocking Ex
399399
:ref:`RedisStore <lock-store-redis>` remote no yes yes yes
400400
:ref:`SemaphoreStore <lock-store-semaphore>` local yes no no no
401401
:ref:`ZookeeperStore <lock-store-zookeeper>` remote no no no no
402+
:ref:`DynamoDbStore <lock-store-dynamodb>` remote no yes no yes
402403
========================================================== ====== ======== ======== ======= =============
403404

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

702+
.. _lock-store-dynamodb:
703+
704+
DynamoDbStore
705+
~~~~~~~~~~~~~
706+
707+
The DynamoDbStore saves locks on a Amazon DynamoDB table. Install it by running:
708+
709+
.. code-block:: terminal
710+
711+
$ composer require symfony/amazon-dynamodb-lock
712+
713+
It requires a `DynamoDbClient`_ instance or a `Data Source Name (DSN)`_.
714+
This store does not support blocking, and expects a TTL to avoid stalled locks::
715+
716+
use Symfony\Component\Lock\Bridge\DynamoDb\Store\DynamoDbStore;
717+
718+
// a DynamoDbClient instance or DSN
719+
$dynamoDbClientOrDSN = 'dynamodb://default/lock';
720+
$store = new DynamoDbStore($dynamoDbClientOrDSN);
721+
722+
The table where values are stored is created automatically on the first call to
723+
the :method:`Symfony\\Component\\Lock\\Bridge\\DynamoDb\\DynamoDbStore::save` method.
724+
You can also create this table explicitly by calling the
725+
:method:`Symfony\\Component\\Lock\\Bridge\\DynamoDb\\DynamoDbStore::createTable` method in
726+
your code.
727+
701728
Reliability
702729
-----------
703730

@@ -1049,3 +1076,4 @@ are still running.
10491076
.. _`readers-writer lock`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock
10501077
.. _`priority policy`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Priority_policies
10511078
.. _`PCNTL`: https://www.php.net/manual/book.pcntl.php
1079+
.. _`DynamoDbClient`: https://async-aws.com/clients/dynamodb.html

lock.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ this behavior by using the ``lock`` key like:
6161
lock: 'sqlsrv:server=127.0.0.1;Database=app'
6262
lock: 'oci:host=127.0.0.1;dbname=app'
6363
lock: 'mongodb://127.0.0.1/app?collection=lock'
64+
lock: 'dynamodb://127.0.0.1/lock'
6465
lock: '%env(LOCK_DSN)%'
6566
# using an existing service
6667
lock: 'snc_redis.default'
@@ -119,6 +120,8 @@ this behavior by using the ``lock`` key like:
119120
120121
<framework:resource>mongodb://127.0.0.1/app?collection=lock</framework:resource>
121122
123+
<framework:resource>dynamodb://127.0.0.1/lock</framework:resource>
124+
122125
<framework:resource>%env(LOCK_DSN)%</framework:resource>
123126
124127
<!-- using an existing service -->
@@ -157,6 +160,7 @@ this behavior by using the ``lock`` key like:
157160
->resource('default', ['sqlsrv:server=127.0.0.1;Database=app'])
158161
->resource('default', ['oci:host=127.0.0.1;dbname=app'])
159162
->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
163+
->resource('default', ['dynamodb://127.0.0.1/lock'])
160164
->resource('default', [env('LOCK_DSN')])
161165
// using an existing service
162166
->resource('default', ['snc_redis.default'])

0 commit comments

Comments
 (0)