@@ -28,7 +28,7 @@ Locks are used to guarantee exclusive access to some shared resource. In
28
28
Symfony applications, you can use locks for example to ensure that a command is
29
29
not executed more than once at the same time (on the same or different servers).
30
30
31
- In order to manage the state of locks, you first need to create a ``Store ``
31
+ In order to manage the state of locks, a ``Store `` needs to be created first
32
32
and then use the :class: `Symfony\\ Component\\ Lock\\ Factory ` class to actually
33
33
create the lock for some resource::
34
34
@@ -120,6 +120,12 @@ method, the resource will stay locked until the timeout::
120
120
To avoid letting the lock in a locking state, it's recommended to wrap the
121
121
job in a try/catch/finally block to always try to release the expiring lock.
122
122
123
+ .. tip ::
124
+
125
+ If you forget to release the lock, it will automaticaly be done on instance
126
+ destruction, but it's recommended to release it as soon as the lock is no
127
+ longer required.
128
+
123
129
In case of long-running tasks, it's better to start with a not too long TTL and
124
130
then use the :method: `Symfony\\ Component\\ Lock\\ LockInterface::refresh ` method
125
131
to reset the TTL to its original value::
@@ -235,7 +241,7 @@ is being acquired, it forwards the call to all the managed stores, and it
235
241
collects their responses. If a simple majority of stores have acquired the lock,
236
242
then the lock is considered as acquired; otherwise as not acquired::
237
243
238
- use Symfony\Component\Lock\Quorum \ConsensusStrategy;
244
+ use Symfony\Component\Lock\Strategy \ConsensusStrategy;
239
245
use Symfony\Component\Lock\Store\CombinedStore;
240
246
use Symfony\Component\Lock\Store\RedisStore;
241
247
@@ -251,7 +257,7 @@ then the lock is considered as acquired; otherwise as not acquired::
251
257
252
258
Instead of the simple majority strategy (``ConsensusStrategy ``) an
253
259
``UnanimousStrategy `` can be used to require the lock to be acquired in all
254
- he stores.
260
+ the stores.
255
261
256
262
.. _`locks` : https://en.wikipedia.org/wiki/Lock_(computer_science)
257
263
.. _Packagist : https://packagist.org/packages/symfony/lock
0 commit comments