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