@@ -24,16 +24,21 @@ Locks are used to guarantee exclusive access to some shared resource. In
24
24
Symfony applications, you can use locks for example to ensure that a command is
25
25
not executed more than once at the same time (on the same or different servers).
26
26
27
- Locks are created using a :class: `Symfony\\ Component\\ Lock\\ Factory ` class,
27
+ Locks are created using a :class: `Symfony\\ Component\\ Lock\\ LockFactory ` class,
28
28
which in turn requires another class to manage the storage of locks::
29
29
30
- use Symfony\Component\Lock\Factory ;
30
+ use Symfony\Component\Lock\LockFactory ;
31
31
use Symfony\Component\Lock\Store\SemaphoreStore;
32
32
33
33
$store = new SemaphoreStore();
34
- $factory = new Factory ($store);
34
+ $factory = new LockFactory ($store);
35
35
36
- The lock is created by calling the :method: `Symfony\\ Component\\ Lock\\ Factory::createLock `
36
+ .. versionadded :: 4.4
37
+
38
+ The ``Symfony\Component\Lock\LockFactory `` class was introduced in Symfony
39
+ 4.4. In previous versions it was called ``Symfony\Component\Lock\Factory ``.
40
+
41
+ The lock is created by calling the :method: `Symfony\\ Component\\ Lock\\ LockFactory::createLock `
37
42
method. Its first argument is an arbitrary string that represents the locked
38
43
resource. Then, a call to the :method: `Symfony\\ Component\\ Lock\\ LockInterface::acquire `
39
44
method will try to acquire the lock::
@@ -56,7 +61,7 @@ method can be safely called repeatedly, even if the lock is already acquired.
56
61
Unlike other implementations, the Lock Component distinguishes locks
57
62
instances even when they are created for the same resource. If a lock has
58
63
to be used by several services, they should share the same ``Lock `` instance
59
- returned by the ``Factory ::createLock `` method.
64
+ returned by the ``LockFactory ::createLock `` method.
60
65
61
66
.. tip ::
62
67
@@ -77,13 +82,13 @@ until the lock is acquired.
77
82
Some of the built-in ``Store `` classes support this feature. When they don't,
78
83
they can be decorated with the ``RetryTillSaveStore `` class::
79
84
80
- use Symfony\Component\Lock\Factory ;
85
+ use Symfony\Component\Lock\LockFactory ;
81
86
use Symfony\Component\Lock\Store\RedisStore;
82
87
use Symfony\Component\Lock\Store\RetryTillSaveStore;
83
88
84
89
$store = new RedisStore(new \Predis\Client('tcp://localhost:6379'));
85
90
$store = new RetryTillSaveStore($store);
86
- $factory = new Factory ($store);
91
+ $factory = new LockFactory ($store);
87
92
88
93
$lock = $factory->createLock('notification-flush');
89
94
$lock->acquire(true);
0 commit comments