@@ -98,7 +98,7 @@ infinitely.
98
98
99
99
To fill this gap, the remote ``Stores `` provide an expirable mechanism: The lock
100
100
is acquired for a defined amount of time (named TTL for Time To Live).
101
- When the timeout occured , the lock is automatically released even if the locker
101
+ When the timeout occurred , the lock is automatically released even if the locker
102
102
don't call the ``release() `` method.
103
103
104
104
That's why, when you create a lock on an expirable ``Store ``. You have to choose
@@ -126,13 +126,13 @@ the ``resource`` will stay lock till the timeout.
126
126
.. tip ::
127
127
128
128
To avoid letting the Lock in a locking state, try to always release an
129
- expirable lock by wraping the job in a try/catch block for instance.
129
+ expirable lock by wrapping the job in a try/catch block for instance.
130
130
131
131
When you have to work on a really long task, you should not set the TTL to
132
132
overlap the duration of this task. Instead, the Lock Component expose a
133
133
:method: `Symfony\\ Component\\ Lock\\ LockInterface::refresh ` method in order to
134
134
put off the TTL of the Lock. Thereby you can choose a small initial TTL, and
135
- regulary refresh the lock
135
+ regularly refresh the lock
136
136
137
137
.. code-block :: php
138
138
@@ -145,7 +145,7 @@ regulary refresh the lock
145
145
$lock->acquire();
146
146
try {
147
147
while (!$finished) {
148
- // perfom a small part of the job.
148
+ // perform a small part of the job.
149
149
150
150
$lock->refresh();
151
151
// resource is locked for 30 more seconds.
@@ -186,10 +186,8 @@ FlockStore
186
186
~~~~~~~~~~
187
187
188
188
The FlockStore use the fileSystem on the local computer to lock and store the
189
- ``resource ``.
190
- It does not supports expiration, but the lock is automaticaly released when the
191
- PHP process is terminated.
192
-
189
+ ``resource ``. It does not supports expiration, but the lock is automatically
190
+ released when the PHP process is terminated.
193
191
194
192
.. code-block :: php
195
193
@@ -206,7 +204,6 @@ file will be created.
206
204
We suggest to use local file, or to use a Store dedicated to remote usage
207
205
like Redis or Memcached.
208
206
209
-
210
207
.. _Packagist : https://packagist.org/packages/symfony/lock
211
208
212
209
.. _lock-store-memcached :
@@ -221,7 +218,6 @@ The MemcachedStore stores state of ``resource`` in a Memcached server. This
221
218
222
219
Memcached does not supports TTL lower than 1 seconds.
223
220
224
-
225
221
It requires to have installed Memcached and have created a connection that
226
222
implements the ``\Memcached `` classes::
227
223
@@ -263,7 +259,6 @@ SemaphoreStore
263
259
264
260
The SemaphoreStore uses the PHP semaphore function to lock a ``resources ``.
265
261
266
-
267
262
.. code-block :: php
268
263
269
264
use Symfony\Component\Lock\Store\SemaphoreStore;
@@ -276,14 +271,14 @@ CombinedStore
276
271
~~~~~~~~~~~~~
277
272
278
273
The CombinedStore synchronize several ``Stores `` together. When it's used to
279
- acquired a Lock, it forward the call to the managed ``Stores ``, and regarding the
280
- result, uses a quorum to decide whether or not the lock is acquired.
274
+ acquired a Lock, it forwards the call to the managed ``Stores ``, and regarding
275
+ the result, uses a quorum to decide whether or not the lock is acquired.
281
276
282
277
.. note ::
283
278
284
- This ``Store `` is usefull for High availability application. You can provide
279
+ This ``Store `` is useful for High availability application. You can provide
285
280
several Redis Server, and use theses server to manage the Lock. A
286
- MajorityQuorum is enougth to safely acquire a lock while it allow some Redis
281
+ MajorityQuorum is enough to safely acquire a lock while it allow some Redis
287
282
server failure.
288
283
289
284
.. code-block :: php
@@ -293,7 +288,7 @@ result, uses a quorum to decide whether or not the lock is acquired.
293
288
use Symfony\Component\Lock\Store\RedisStore;
294
289
295
290
$stores = [];
296
- foreach ([ 'server1', 'server2', 'server3'] as $server) {
291
+ foreach (array( 'server1', 'server2', 'server3') as $server) {
297
292
$redis= new \Redis();
298
293
$redis->connect($server);
299
294
@@ -302,12 +297,10 @@ result, uses a quorum to decide whether or not the lock is acquired.
302
297
303
298
$store = new CombinedStore($stores, new MajorityQuorum());
304
299
305
-
306
300
.. tip ::
307
301
308
302
You can use the CombinedStore with the UnanimousQuorum to implement chained
309
303
``Stores ``. It'll allow you to acquire easy local locks before asking for a
310
304
remote lock
311
305
312
-
313
306
.. _Packagist : https://packagist.org/packages/symfony/lock
0 commit comments