Skip to content

Commit 96722fd

Browse files
committed
minor #11931 [Lock] Renamed the Lock factory class (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch (closes #11931). Discussion ---------- [Lock] Renamed the Lock factory class Fixes #11928. Commits ------- b4ab572 [Lock] Renamed the Lock factory class
2 parents d7e18fa + b4ab572 commit 96722fd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

components/lock.rst

+12-7
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,21 @@ Locks are used to guarantee exclusive access to some shared resource. In
2424
Symfony applications, you can use locks for example to ensure that a command is
2525
not executed more than once at the same time (on the same or different servers).
2626

27-
Locks are created using a :class:`Symfony\\Component\\Lock\\Factory` class,
27+
Locks are created using a :class:`Symfony\\Component\\Lock\\LockFactory` class,
2828
which in turn requires another class to manage the storage of locks::
2929

30-
use Symfony\Component\Lock\Factory;
30+
use Symfony\Component\Lock\LockFactory;
3131
use Symfony\Component\Lock\Store\SemaphoreStore;
3232

3333
$store = new SemaphoreStore();
34-
$factory = new Factory($store);
34+
$factory = new LockFactory($store);
3535

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`
3742
method. Its first argument is an arbitrary string that represents the locked
3843
resource. Then, a call to the :method:`Symfony\\Component\\Lock\\LockInterface::acquire`
3944
method will try to acquire the lock::
@@ -56,7 +61,7 @@ method can be safely called repeatedly, even if the lock is already acquired.
5661
Unlike other implementations, the Lock Component distinguishes locks
5762
instances even when they are created for the same resource. If a lock has
5863
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.
6065

6166
.. tip::
6267

@@ -77,13 +82,13 @@ until the lock is acquired.
7782
Some of the built-in ``Store`` classes support this feature. When they don't,
7883
they can be decorated with the ``RetryTillSaveStore`` class::
7984

80-
use Symfony\Component\Lock\Factory;
85+
use Symfony\Component\Lock\LockFactory;
8186
use Symfony\Component\Lock\Store\RedisStore;
8287
use Symfony\Component\Lock\Store\RetryTillSaveStore;
8388

8489
$store = new RedisStore(new \Predis\Client('tcp://localhost:6379'));
8590
$store = new RetryTillSaveStore($store);
86-
$factory = new Factory($store);
91+
$factory = new LockFactory($store);
8792

8893
$lock = $factory->createLock('notification-flush');
8994
$lock->acquire(true);

0 commit comments

Comments
 (0)