@@ -24,16 +24,21 @@ Locks are used to guarantee exclusive access to some shared resource. In
2424Symfony applications, you can use locks for example to ensure that a command is
2525not executed more than once at the same time (on the same or different servers).
2626
27- <
6CAA
div class="diff-text-inner">Locks are created using a :class: `Symfony\\ Component\\ Lock\\ Factory ` class,27+ Locks are created using a :class: `Symfony\\ Component\\ Lock\\ LockFactory ` class,
2828which 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 `
3742method. Its first argument is an arbitrary string that represents the locked
3843resource. Then, a call to the :method: `Symfony\\ Component\\ Lock\\ LockInterface::acquire `
3944method 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.
7782Some of the built-in ``Store `` classes support this feature. When they don't,
7883they 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);
@@ -208,8 +213,10 @@ Available Stores
208213----------------
209214
210215Locks are created and managed in ``Stores ``, which are classes that implement
211- :class: `Symfony\\ Component\\ Lock\\ StoreInterface `. The component includes the
212- following built-in store types:
216+ :class: `Symfony\\ Component\\ Lock\\ PersistStoreInterface ` and, optionally,
217+ :class: `Symfony\\ Component\\ Lock\\ BlockingStoreInterface `.
218+
219+ The component includes the following built-in store types:
213220
214221============================================ ====== ======== ========
215222Store Scope Blocking Expiring
@@ -222,6 +229,12 @@ Store Scope Blocking Expiring
222229:ref: `ZookeeperStore <lock-store-zookeeper >` remote no no
223230============================================ ====== ======== ========
224231
232+ .. versionadded :: 4.4
233+
234+ The ``PersistStoreInterface `` and ``BlockingStoreInterface `` interfaces were
235+ introduced in Symfony 4.4. In previous versions there was only one interface
236+ called ``Symfony\Component\Lock\StoreInterface ``.
237+
225238.. _lock-store-flock :
226239
227240FlockStore
0 commit comments