@@ -273,21 +273,21 @@ Remote stores (:ref:`MemcachedStore <lock-store-memcached>` and
273273:ref: `RedisStore <lock-store-redis >`) use an unique token to recognize the true
274274owner of the lock. This token is stored in the
275275:class: `Symfony\\ Component\\ Lock\\ Key ` object and is used internally by the
276- ``Lock ``, therefore this Key must not be shared between processes (Session ,
277- Caching , fork, ...).
276+ ``Lock ``, therefore this key must not be shared between processes (session ,
277+ caching , fork, ...).
278278
279279.. caution ::
280280
281- Do not share a Key between processes.
281+ Do not share a key between processes.
282282
283- Every concurrent process must store the ``Lock `` in the same Server otherwise two
284- distinguished machines may allow two distinguished process to acquire the same ``Lock ``.
283+ Every concurrent process must store the ``Lock `` in the same server. Otherwise two
284+ different machines may allow two different processes to acquire the same ``Lock ``.
285285
286286.. caution ::
287287
288- To guarantee that the same Server will always be sure , do not use Memcached
288+ To guarantee that the same server will always be safe , do not use Memcached
289289 behind a LoadBalancer, a cluster or round-robin DNS. Even if the main server
290- is Down , the calls must not be forwarded to a backup or failover server.
290+ is down , the calls must not be forwarded to a backup or failover server.
291291
292292Expiring Stores
293293~~~~~~~~~~~~~~~
@@ -298,11 +298,11 @@ only for the defined duration of time. If the task takes longer to be
298298accomplished, then the lock can be released by the store and acquired by
299299someone else.
300300
301- The ``Lock `` provide several methods to check it health. The ``isExpired ``
302- method provide an quick way to check whether or not it lifetime is over.
303- While the `` getRemainingLifetime `` method returns it time to live in seconds.
301+ The ``Lock `` provides several methods to check its health. The ``isExpired() ``
302+ method checks whether or not it lifetime is over and the `` getRemainingLifetime() ``
303+ method returns its time to live in seconds.
304304
305- With the above methods, a more robust code would be::
305+ Using the above methods, a more robust code would be::
306306
307307 // ...
308308 $lock = $factory->createLock('invoice-publication', 30);
@@ -311,7 +311,7 @@ With the above methods, a more robust code would be::
311311 while (!$finished) {
312312 if ($lock->getRemainingLifetime() <= 5) {
313313 if ($lock->isExpired()) {
314- // reliability was lost, perform a rollback or send a notification
314+ // lock was lost, perform a rollback or send a notification
315315 throw new \RuntimeException('Lock lost during the overall process');
316316 }
317317
@@ -323,49 +323,48 @@ With the above methods, a more robust code would be::
323323
324324.. caution ::
325325
326- Choose wisely the lifetime of the ``Lock ``. And check if it remaining
326+ Choose wisely the lifetime of the ``Lock `` and check whether its remaining
327327 time to leave is enough to perform the task.
328328
329329.. caution ::
330330
331- Storing a ``Lock `` could take time. Even if, most of the time, it take
332- few milliseconds, Network, may have trouble and the duration to perform
333- this simple task could be up to few seconds. Take it into accound when
334- choosing the right TTL.
331+ Storing a ``Lock `` usually takes a few milliseconds, but network conditions
332+ may increase that time a lot (up to a few seconds). Take that into account
333+ when choosing the right TTL.
335334
336- By design, Lock are stored in Server with a defined Lifetime . If the date or
337- time of the machine changes, a Lock could be released sooner than expected.
335+ By design, locks are stored in servers with a defined lifetime . If the date or
336+ time of the machine changes, a lock could be released sooner than expected.
338337
339338.. caution ::
340339
341- To guarantee that date wouldn 't change, the NTP service should be disabled
342- and the date should be updated when while the service is stopped.
340+ To guarantee that date won 't change, the NTP service should be disabled
341+ and the date should be updated when the service is stopped.
343342
344343FlockStore
345344~~~~~~~~~~
346345
347346By using the file system, this ``Store `` is reliable as long as concurrent
348347processes use the same physical directory to stores locks.
349348
350- Processes must run on the same Machine, Virtual Machine or Container .
349+ Processes must run on the same machine, virtual machine or container .
351350Be careful when updating a Kubernetes or Swarm service because for a short
352- period of time, there can be 2 running containers in parallel.
351+ period of time, there can be two running containers in parallel.
353352
354- The absolute path to the directory must remain the same. Be careful to
355- symlinks on the path that could change at anytime: Capistrano and blue/green
356- deployment often use that trick. Be careful when the path to that directory
357- change between 2 deployments.
353+ The absolute path to the directory must remain the same. Be careful of symlinks
354+ that could change at anytime: Capistrano and blue/green deployment often use
355+ that trick. Be careful when the path to that directory changes between two
356+ deployments.
358357
359358Some file systems (such as some types of NFS) do not support locking.
360359
361360.. caution ::
362361
363- All concurrent processes MUST use the same physical file system by running
362+ All concurrent processes must use the same physical file system by running
364363 on the same machine and using the same absolute path to locks directory.
365364
366365 By definition, usage of ``FlockStore `` in an HTTP context is incompatible
367- with multiple front server , unless to be sure that the same resource will
368- alway be locked on the same machine or to use a well configured shared file
366+ with multiple front servers , unless to ensure that the same resource will
367+ always be locked on the same machine or to use a well configured shared file
369368 system.
370369
371370Files on file system can be removed during a maintenance operation. For instance
@@ -375,26 +374,26 @@ it is in case of ``Lock`` reused between requests.
375374
376375.. caution ::
377376
378- Do not store locks on a volatil file system if they have to be reused during
377+ Do not store locks on a volatile file system if they have to be reused in
379378 several requests.
380379
381380MemcachedStore
382381~~~~~~~~~~~~~~
383382
384- The way Memcached works is to store items in Memory, that's means that by using
383+ The way Memcached works is to store items in memory. That means that by using
385384the :ref: `MemcachedStore <lock-store-memcached >` the locks are not persisted
386385and may disappear by mistake at anytime.
387386
388- If the Memcached service or the machine hosting it restarts, every locks would
389- be lost without notify running processes.
387+ If the Memcached service or the machine hosting it restarts, every lock would
388+ be lost without notifying the running processes.
390389
391390.. caution ::
392391
393- To avoid that someone else acquires a lock after a restart, we recommend
394- to delayed service start and wait at least as long as the longest lock TTL.
392+ To avoid that someone else acquires a lock after a restart, it's recommended
393+ to delay service start and wait at least as long as the longest lock TTL.
395394
396- By default Memcached use a LRU mechanism to remove old entries when the service
397- need space to add new items.
395+ By default Memcached uses a LRU mechanism to remove old entries when the service
396+ needs space to add new items.
398397
399398.. caution ::
400399
@@ -403,73 +402,73 @@ need space to add new items.
403402 Memcached service away from Cache.
404403
405404When the Memcached service is shared and used for multiple usage, Locks could be
406- removed by mistake. For instance some implementation of the PSR-6 ``clear ``
407- method use the Memcached's ``flush `` method which purge and remove everything.
405+ removed by mistake. For instance some implementation of the PSR-6 ``clear() ``
406+ method uses the Memcached's ``flush() `` method which purges and removes everything.
408407
409408.. caution ::
410409
411- The method ``flush `` MUST not be called, or Locks should be stored in a
410+ The method ``flush() `` must not be called, or locks should be stored in a
412411 dedicated Memcached service away from Cache.
413412
414413RedisStore
415414~~~~~~~~~~
416415
417- The way Redis works is to store items in Memory, that's means that by using
416+ The way Redis works is to store items in memory. That means that by using
418417the :ref: `RedisStore <lock-store-redis >` the locks are not persisted
419418and may disappear by mistake at anytime.
420419
421420If the Redis service or the machine hosting it restarts, every locks would
422- be lost without notify running processes.
421+ be lost without notifying the running processes.
423422
424423.. caution ::
425424
426- To avoid that someone else acquires a lock after a restart, we recommend
427- to delayed service start and wait at least as long as the longest lock TTL.
425+ To avoid that someone else acquires a lock after a restart, it's recommended
426+ to delay service start and wait at least as long as the longest lock TTL.
428427
429428.. tips ::
430429
431430 Redis can be configured to persist items on disk, but this option would
432431 slow down writes on the service. This could go against other uses of the
433432 server.
434433
435- When the Redis service is shared and used for multiple usage, Locks could be
434+ When the Redis service is shared and used for multiple usages, locks could be
436435removed by mistake.
437436
438437.. caution ::
439438
440- The command ``FLUSHDB `` MUST not be called, or Locks should be stored in a
439+ The command ``FLUSHDB `` must not be called, or locks should be stored in a
441440 dedicated Redis service away from Cache.
442441
443442CombinedStore
444443~~~~~~~~~~~~~
445444
446- Combined stores allows to store locks across several backend . It's a common
445+ Combined stores allow to store locks across several backends . It's a common
447446mistake to think that the lock mechanism will be more reliable. This is wrong
448- The ``CombinedStore `` will be, at best, as reliable than the less reliable of
447+ The ``CombinedStore `` will be, at best, as reliable as the least reliable of
449448all managed stores. As soon as one managed store returns erroneous information,
450- the ``CombinedStore `` would be not reliable.
449+ the ``CombinedStore `` won't be reliable.
451450
452451.. caution ::
453452
454- All concurrent processes MUST use the same configuration. with the same
453+ All concurrent processes must use the same configuration, with the same
455454 amount of managed stored and the same endpoint.
456455
457456.. tips ::
458457
459- Instead of using Cluster of Redis or memcached servers, we recommend to use
460- a ``CombinedStore `` with & single server per managed store.
458+ Instead of using a cluster of Redis or Memcached servers, it's better to use
459+ a ``CombinedStore `` with a single server per managed store.
461460
462461SemaphoreStore
463462~~~~~~~~~~~~~~
464463
465- Semaphore are handled by the Kernel level, to be reliable, processes must run
466- on the same Machine, Virtual Machine or Container.
467- Be careful when updating a Kubernetes or Swarm service because for a short
468- period of time, there can be 2 running containers in parallel.
464+ Semaphores are handled by the Kernel level. In order to be reliable, processes
465+ must run on the same machine, virtual machine or container. Be careful when
466+ updating a Kubernetes or Swarm service because for a short period of time, there
467+ can be two running containers in parallel.
469468
470469.. caution ::
471470
472- All concurrent processes MUST use the same machine. Before starting a
471+ All concurrent processes must use the same machine. Before starting a
473472 concurrent process on a new machine, check that other process are stopped
474473 on the old one.
475474
@@ -478,8 +477,8 @@ Overall
478477
479478Changing the configuration of stores should be done very carefully. For
480479instance, during the deployment of a new version. Processes with new
481- configuration MUST NOT be started while Old processes with old configuration
482- are still running
480+ configuration must not be started while old processes with old configuration
481+ are still running.
483482
484483.. _`locks` : https://en.wikipedia.org/wiki/Lock_(computer_science)
485484.. _Packagist : https://packagist.org/packages/symfony/lock
0 commit comments