File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -30,30 +30,25 @@ Then, you can use the :class:`Symfony\\Component\\Lock\\Factory` to create a
3030Lock for your ``resource ``.
3131
3232The :method: `Symfony\\ Component\\ Lock\\ LockInterface::acquire ` method tries to
33- acquire the lock. If the lock can not be acquired, the method throws a
34- :class: `Symfony\\ Component\\ Lock\\ Exception\\ LockConflictedException `. You can
35- safely call the ``acquire() `` method several times, even if you already acquired
36- it.
33+ acquire the lock. If the lock can not be acquired, the method returns ``false ``.
34+ You can safely call the ``acquire() `` method several times, even if you already
35+ acquired it.
3736
3837.. code-block :: php
3938
4039 use Symfony\Component\Lock\Factory;
4140 use Symfony\Component\Lock\Store\SemaphoreStore;
42- use Symfony\Component\Lock\Exception\LockConflictedException;
4341
4442 $store = new SemaphoreStore();
4543 $factory = new Factory($store);
4644 $lock = $factory->createLock('invoice-pdf-generation');
4745
48- try {
49- $lock->acquire();
46+ if ($lock->acquire()) {
5047 // the resource "invoice-pdf-generation" is locked.
5148
5249 // You can compute and generate invoice safely here.
5350
5451 $lock->release();
55- } catch (LockConflictedException $e) {
56- // the resource "invoice-pdf-generation" is already locked by another process
5752 }
5853
5954 The first argument of ``createLock `` is a string representation of the
You can’t perform that action at this time.
0 commit comments