You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Name of the table where the locks will be stored
157
+
name: 'locks'
158
+
},
159
+
160
+
// Credentials to use to connect to DynamoDB
161
+
credentials: {
162
+
accessKeyId: '...',
163
+
secretAccessKey: '...'
164
+
}
165
+
})
166
+
167
+
const lockFactory =newLockFactory(store)
168
+
169
+
```
170
+
:::
171
+
131
172
The DynamoDB table will be automatically created if it does not exists. Otherwise, you can create it manually and specify the name of the table in the options.
132
173
133
174
### Options
@@ -155,88 +196,177 @@ All SQL drivers accept the following options:
The database drivers use the same strategy as Laravel's Locks. The strategy is fairly simple : Just insert a row and rely on the database primary key constraint to prevent duplicates. If the insert fails, it means the lock already exists. This is briefly explained by Aaron Francis in [this article](https://aaronfrancis.com/2021/the-exceeding-cleverness-of-laravels-database-locks).
The first argument is the resource/key to lock. This is an arbitrary string that will be used to identify the lock. The second argument is the duration of the lock. It can be a number of milliseconds, a string like `1s` or `1m` ( see [lukee/ms documentation](https://github.com/lukeed/ms), or even `null` if you want to create a lock that never expires.
19
+
The first argument is the resource/key to lock. This is an arbitrary string that will be used to identify the lock. The second argument is the duration of the lock. It can be a number of milliseconds, a string like `1s` or `1m` ( see [lukeed/ms documentation](https://github.com/lukeed/ms), or even `null` if you want to create a lock that never expires.
20
20
21
21
Note that the duration you are passing is the duration of the lease. This means that the lock will be automatically released after this duration. This is safe to always pass a duration, even if you are releasing the lock manually afterwards ( see below ). Having a duration will prevent the lock from being stuck forever if the process crashes before releasing it ( We call this a **Deadlock** ).
0 commit comments