@@ -171,7 +171,6 @@ Store Scope Blocking Expiring
171
171
============================================ ====== ======== ========
172
172
:ref: `FlockStore <lock-store-flock >` local yes no
173
173
:ref: `MemcachedStore <lock-store-memcached >` remote no yes
174
- :ref: `MongoDbStore <lock-store-mongodb >` remote no yes
175
174
:ref: `PdoStore <lock-store-pdo >` remote no yes
176
175
:ref: `RedisStore <lock-store-redis >` remote no yes
177
176
:ref: `SemaphoreStore <lock-store-semaphore >` local yes no
@@ -218,39 +217,6 @@ support blocking, and expects a TTL to avoid stalled locks::
218
217
219
218
Memcached does not support TTL lower than 1 second.
220
219
221
- .. _lock-store-mongodb :
222
-
223
- MongoDbStore
224
- ~~~~~~~~~~~~
225
-
226
- .. versionadded :: 4.3
227
-
228
- The ``MongoDbStore `` was introduced in Symfony 4.3.
229
-
230
- The MongoDbStore saves locks on a MongoDB server, it requires a
231
- ``\MongoDB\Client `` connection from `mongodb/mongodb `_. This store does not
232
- support blocking and expects a TTL to avoid stalled locks::
233
-
234
- use Symfony\Component\Lock\Store\MongoDbStore;
235
-
236
- $mongoClient = new \MongoDB\Client('mongo://localhost/');
237
-
238
- $options = [
239
- 'database' => 'my-app',
240
- ];
241
-
242
- $store = new MongoDbStore($mongoClient, $options);
243
-
244
- The ``MongoDbStore `` takes the following ``$options ``:
245
-
246
- ============ ========= ========================================================================
247
- Option Default Description
248
- ============ ========= ========================================================================
249
- database The name of the database [Mandatory]
250
- collection ``lock `` The name of the collection
251
- gcProbablity ``0.001 `` Should a TTL Index be created expressed as a probability from 0.0 to 1.0
252
- ============ ========= ========================================================================
253
-
254
220
.. _lock-store-pdo :
255
221
256
222
PdoStore
@@ -387,7 +353,7 @@ Remote Stores
387
353
~~~~~~~~~~~~~
388
354
389
355
Remote stores (:ref: `MemcachedStore <lock-store-memcached >`,
390
- :ref: `MongoDbStore < lock-store-mongodb >`, :ref: ` PdoStore <lock-store-pdo >`,
356
+ :ref: `PdoStore <lock-store-pdo >`,
391
357
:ref: `RedisStore <lock-store-redis >` and
392
358
:ref: `ZookeeperStore <lock-store-zookeeper >`) use a unique token to recognize
393
359
the true owner of the lock. This token is stored in the
@@ -412,7 +378,7 @@ Expiring Stores
412
378
~~~~~~~~~~~~~~~
413
379
414
380
Expiring stores (:ref: `MemcachedStore <lock-store-memcached >`,
415
- :ref: `MongoDbStore < lock-store-mongodb >`, :ref: ` PdoStore <lock-store-pdo >` and
381
+ :ref: `PdoStore <lock-store-pdo >` and
416
382
:ref: `RedisStore <lock-store-redis >`)
417
383
guarantee that the lock is acquired only for the defined duration of time. If
418
384
the task takes longer to be accomplished, then the lock can be released by the
@@ -530,46 +496,6 @@ method uses the Memcached's ``flush()`` method which purges and removes everythi
530
496
The method ``flush() `` must not be called, or locks should be stored in a
531
497
dedicated Memcached service away from Cache.
532
498
533
- MongoDbStore
534
- ~~~~~~~~~~~~
535
-
536
- .. caution ::
537
-
538
- The locked resource name is indexed in the ``_id `` field of the lock
539
- collection. Beware that in MongoDB an indexed field's value can be
540
- `a maximum of 1024 bytes in length `_ inclusive of structural overhead.
541
-
542
- A TTL index MUST BE used on MongoDB 2.2+ to automatically clean up expired locks.
543
- Such an index can be created manually:
544
-
545
- .. code-block :: javascript
546
-
547
- db .lock .ensureIndex (
548
- { " expires_at" : 1 },
549
- { " expireAfterSeconds" : 0 }
550
- )
551
-
552
- Alternatively, the method ``MongoDbStore::createTtlIndex(int $expireAfterSeconds = 0) ``
553
- can be called once to create the TTL index during database setup. Read more
554
- about `Expire Data from Collections by Setting TTL `_ in MongoDB.
555
-
556
- .. tip ::
557
-
558
- ``MongoDbStore `` will attempt to automatically create a TTL index on MongoDB
559
- 2.2+. It's recommended to set constructor option ``gcProbablity = 0.0 `` to
560
- disable this behavior if you have manually dealt with TTL index creation.
561
-
562
- .. caution ::
563
-
564
- This store relies on all PHP application and database nodes to have
565
- synchronized clocks for lock expiry to occur at the correct time. To ensure
566
- locks don't expire prematurely; the lock TTL should be set with enough extra
567
- time in ``expireAfterSeconds `` to account for any clock drift between nodes.
568
-
569
- ``writeConcern ``, ``readConcern `` and ``readPreference `` are not specified by
570
- MongoDbStore meaning the collection's settings will take effect. Read more
571
- about `Replica Set Read and Write Semantics `_ in MongoDB.
572
-
573
499
PdoStore
574
500
~~~~~~~~~~
575
501
@@ -690,13 +616,9 @@ are still running.
690
616
691
617
.. _`ACID` : https://en.wikipedia.org/wiki/ACID
692
618
.. _`locks` : https://en.wikipedia.org/wiki/Lock_(computer_science)
693
- .. _`mongodb/mongodb` : https://packagist.org/packages/mongodb/mongodb
694
619
.. _Packagist : https://packagist.org/packages/symfony/lock
695
620
.. _`PHP semaphore functions` : http://php.net/manual/en/book.sem.php
696
621
.. _`PDO` : https://php.net/pdo
697
622
.. _`Doctrine DBAL Connection` : https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Connection.php
698
623
.. _`Data Source Name (DSN)` : https://en.wikipedia.org/wiki/Data_source_name
699
624
.. _`ZooKeeper` : https://zookeeper.apache.org/
700
- .. _`a maximum of 1024 bytes in length` : https://docs.mongodb.com/manual/reference/limits/#Index-Key-Limit
701
- .. _`Expire Data from Collections by Setting TTL` : https://docs.mongodb.com/manual/tutorial/expire-data/
702
- .. _`Replica Set Read and Write Semantics` : https://docs.mongodb.com/manual/applications/replication/
0 commit comments