@@ -176,6 +176,7 @@ Store Scope Blocking Expiring
176
176
:ref: `PdoStore <lock-store-pdo >` remote no yes
177
177
:ref: `RedisStore <lock-store-redis >` remote no yes
178
178
:ref: `SemaphoreStore <lock-store-semaphore >` local yes no
179
+ :ref: `ZookeeperStore <lock-store-zookeeper >` remote no no
179
180
============================================ ====== ======== ========
180
181
181
182
.. _lock-store-flock :
@@ -324,6 +325,31 @@ the stores.
324
325
working when a single server fails (because this strategy requires that the
325
326
lock is acquired in more than half of the servers).
326
327
328
+ .. _lock-store-zookeeper :
329
+
330
+ ZookeeperStore
331
+ ~~~~~~~~~~~~~~
332
+
333
+ .. versionadded :: 4.2
334
+ The ZookeeperStore was introduced Symfony 4.2.
335
+
336
+ The ZookeeperStore saves locks on a Zookeeper server, it requires a Zookeeper
337
+ connection implementing the ``\Zookeeper `` class. This store does not
338
+ support blocking and expiration but the lock is automatically released when the
339
+ PHP process is terminated::
340
+
341
+ use Symfony\Component\Lock\Store\ZookeeperStore;
342
+
343
+ $zookeeper_server = 'localhost:2181'; // For High Availablity Cluster you can pass 'localhost1:2181,localhost2:2181,localhost3:2181'
344
+ $zookeeper = new \Zookeeper($zookeeper_server);
345
+
346
+ $store = new ZookeeperStore($zookeeper);
347
+
348
+ .. note ::
349
+
350
+ Zookeeper does not require a TTL as the nodes used for locking are ephemeral and die when the PHP process is terminated.
351
+
352
+
327
353
Reliability
328
354
-----------
329
355
@@ -334,8 +360,8 @@ Remote Stores
334
360
~~~~~~~~~~~~~
335
361
336
362
Remote stores (:ref: `MemcachedStore <lock-store-memcached >`,
337
- :ref: `PdoStore <lock-store-pdo >` and :ref: `RedisStore <lock-store-redis >`) use
338
- a unique token to recognize the true owner of the lock. This token is stored
363
+ :ref: `PdoStore <lock-store-pdo >`, :ref: `RedisStore <lock-store-redis >`) and :ref: ` ZookeeperStore < lock-store-zookeeper >`)
364
+ use a unique token to recognize the true owner of the lock. This token is stored
339
365
in the :class: `Symfony\\ Component\\ Lock\\ Key ` object and is used internally by
340
366
the ``Lock ``, therefore this key must not be shared between processes (session,
341
367
caching, fork, ...).
@@ -560,6 +586,26 @@ can be two running containers in parallel.
560
586
concurrent process on a new machine, check that other process are stopped
561
587
on the old one.
562
588
589
+ ZookeeperStore
590
+ ~~~~~~~~~~~~~~
591
+
592
+ The way ZookeeperStore works is by maintaining locks as ephemeral nodes on the server. That means that by using
593
+ the :ref: `ZookeeperStore <lock-store-zookeeper >` the locks will be automatically released at the end of the session
594
+ in case the client cannot unlock for any reason.
595
+
596
+ If the Zookeeper service or the machine hosting it restarts, every lock would
597
+ be lost without notifying the running processes.
598
+
599
+ .. tip ::
600
+
601
+ To use Zookeeper's High Availability feature, you can setup a cluster of multiple servers so that in case one of
602
+ the server goes down, the majority will still be up and serving the requests. All the available servers in the
603
+ cluster will see the same state.
604
+
605
+ .. note ::
606
+ As this store does not support multi-level node locks,
607
+ since the clean up of intermediate nodes becomes an overhead, all locks are maintained at the root level.
608
+
563
609
Overall
564
610
~~~~~~~
565
611
0 commit comments