@@ -293,29 +293,51 @@ The MongoDbStore saves locks on a MongoDB server ``>=2.2``, it requires a
293
293
This store does not support blocking and expects a TTL to
294
294
avoid stalled locks::
295
295
296
- use MongoDB\Client;
297
296
use Symfony\Component\Lock\Store\MongoDbStore;
298
297
299
- $client = new Client('mongo://localhost/');
300
-
298
+ $mongo = 'mongodb://localhost/database?collection=lock';
301
299
$options = [
302
- 'database' => 'my-app',
300
+ 'gcProbablity' => 0.001,
301
+ 'database' => 'myapp',
303
302
'collection' => 'lock',
303
+ 'uriOptions' => [],
304
+ 'driverOptions' => [],
304
305
];
306
+ $store = new MongoDbStore($mongo, $options);
307
+
308
+ The ``MongoDbStore `` takes the following ``$options `` (depending on the first parameter type):
309
+
310
+ ============= ================================================================================================
311
+ Option Description
312
+ ============= ================================================================================================
313
+ gcProbablity Should a TTL Index be created expressed as a probability from 0.0 to 1.0 (Defaults to ``0.001 ``)
314
+ database The name of the database
315
+ collection The name of the collection
316
+ uriOptions Array of uri options for `MongoDBClient::__construct `_
317
+ driverOptions Array of driver options for `MongoDBClient::__construct `_
318
+ ============= ================================================================================================
319
+
320
+ When the first parameter is a:
321
+
322
+ ``MongoDB\Collection ``:
305
323
306
- $store = new MongoDbStore($client, $options);
324
+ - ``$options['database'] `` is ignored
325
+ - ``$options['collection'] `` is ignored
307
326
308
- The ``MongoDbStore `` takes the following options (depending on the first parameter type):
327
+ ``MongoDB\Client ``:
328
+
329
+ - ``$options['database'] `` is mandatory
330
+ - ``$options['collection'] `` is mandatory
331
+
332
+ `MongoDB Connection String `_:
333
+
334
+ - ``/path `` is used otherwise ``$options['database'] ``, at least one is mandatory
335
+ - ``?collection= `` is used otherwise ``$options['collection'] ``, at least one is mandatory
336
+
337
+ .. note ::
309
338
310
- ============= ================================= ========= ========================================================================
311
- Option First Parameter Type Default Description
312
- ============= ================================= ========= ========================================================================
313
- gcProbablity any ``0.001 `` Should a TTL Index be created expressed as a probability from 0.0 to 1.0
314
- database ``\MongoDB\Client `` or ``string `` The name of the database [Mandatory]
315
- collection ``\MongoDB\Client `` or ``string `` ``lock `` The name of the collection
316
- uriOptions ``string `` ``[] `` Array of uri options for `MongoDBClient::__construct `_
317
- driverOptions ``string `` ``[] `` Array of driver options for `MongoDBClient::__construct `_
318
- ============= ================================= ========= ========================================================================
339
+ The ``collection `` querystring parameter is not part of the `MongoDB Connection String `_ definition.
340
+ It is simply used to allow constructing a ``MongoDbStore `` using a `Data Source Name (DSN) `_ without ``$options ``.
319
341
320
342
.. _lock-store-pdo :
321
343
0 commit comments