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