@@ -175,6 +175,7 @@ Store Scope Blocking Expiring
175
175
:ref: `MemcachedStore <lock-store-memcached >` remote no yes
176
176
:ref: `RedisStore <lock-store-redis >` remote no yes
177
177
:ref: `SemaphoreStore <lock-store-semaphore >` local yes no
178
+ :ref: `ZookeeperStore <lock-store-zookeeper >` remote no no
178
179
============================================ ====== ======== ========
179
180
180
181
.. _lock-store-flock :
@@ -281,6 +282,28 @@ the stores.
281
282
working when a single server fails (because this strategy requires that the
282
283
lock is acquired in more than half of the servers).
283
284
285
+ .. _lock-store-zookeeper :
286
+
287
+ ZookeeperStore
288
+ ~~~~~~~~~~~~~~
289
+
290
+ The ZookeeperStore saves locks on a Zookeeper server, it requires a Zookeeper
291
+ connection implementing the ``\Zookeeper `` class. This store does not
292
+ support blocking and expiration but the lock is automatically released when the
293
+ PHP process is terminated
294
+
295
+ use Symfony\C omponent\L ock\S tore\Z ookeeperStore;
296
+
297
+ $zookeeper_server = 'localhost:2181'; // For High Availablity Cluster you can pass 'localhost1:2181,localhost2:2181,localhost3:2181'
298
+ $zookeeper = new \Z ookeeper($zookeeper_server);
299
+
300
+ $store = new ZookeeperStore($zookeeper);
301
+
302
+ .. note ::
303
+
304
+ Zookeeper does not require a TTL as the nodes used for locking are ephemeral and die when the PHP process is terminated.
305
+
306
+
284
307
Reliability
285
308
-----------
286
309
@@ -290,8 +313,8 @@ the component is used in the following way.
290
313
Remote Stores
291
314
~~~~~~~~~~~~~
292
315
293
- Remote stores (:ref: `MemcachedStore <lock-store-memcached >` and
294
- :ref: `RedisStore <lock-store-redis >`) use an unique token to recognize the true
316
+ Remote stores (:ref: `MemcachedStore <lock-store-memcached >`,
317
+ :ref: `RedisStore <lock-store-redis >` and :ref: ` RedisStore < lock-store-zookeeper >` ) use an unique token to recognize the true
295
318
owner of the lock. This token is stored in the
296
319
:class: `Symfony\\ Component\\ Lock\\ Key ` object and is used internally by the
297
320
``Lock ``, therefore this key must not be shared between processes (session,
@@ -493,6 +516,22 @@ can be two running containers in parallel.
493
516
concurrent process on a new machine, check that other process are stopped
494
517
on the old one.
495
518
519
+ ZookeeperStore
520
+ ~~~~~~~~~~
521
+
522
+ The way ZookeeperStore works is by maintaining locks in ephemeral nodes within PHP_LOCK_NODE on the server. That means that by using
523
+ the :ref: `ZookeeperStore <lock-store-zookeeper >` the locks will be automatically released at the end of the session
524
+ in case the client cannot unlock for any reason.
525
+
526
+ If the Zookeeper service or the machine hosting it restarts, every lock would
527
+ be lost without notifying the running processes.
528
+
529
+ .. tip ::
530
+
531
+ To use Zookeeper's High Availability feature, you can setup a cluster of multiple servers so that in case one of
532
+ the server goes down, the majority will still be up and serving the requests. All the available servers in the
533
+ cluster will see the same state.
534
+
496
535
Overall
497
536
~~~~~~~
498
537
0 commit comments