Skip to content

Commit e6b27d1

Browse files
natepagejaviereguiluz
authored andcommitted
[Lock] Add DynamoDbStore
1 parent 3e4ebb5 commit e6b27d1

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::
@@ -703,6 +704,32 @@ PHP process is terminated::
703704
Zookeeper does not require a TTL as the nodes used for locking are ephemeral
704705
and die when the PHP process is terminated.
705706

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

@@ -1054,3 +1081,4 @@ are still running.
10541081
.. _`readers-writer lock`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock
10551082
.. _`priority policy`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Priority_policies
10561083
.. _`PCNTL`: https://www.php.net/manual/book.pcntl.php
1084+
.. _`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)