Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3de20f6

Browse filesBrowse files
author
Joe Bennett
committed
#27345 new Lock\MongoDbStore construction options
1 parent a5c9951 commit 3de20f6
Copy full SHA for 3de20f6

File tree

Expand file treeCollapse file tree

1 file changed

+37
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+37
-15
lines changed

‎components/lock.rst

Copy file name to clipboardExpand all lines: components/lock.rst
+37-15Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -282,29 +282,51 @@ The MongoDbStore saves locks on a MongoDB server ``>=2.2``, it requires a
282282
This store does not support blocking and expects a TTL to
283283
avoid stalled locks::
284284

285-
use MongoDB\Client;
286285
use Symfony\Component\Lock\Store\MongoDbStore;
287286

288-
$client = new Client('mongo://localhost/');
289-
287+
$mongo = 'mongodb://localhost/database?collection=lock';
290288
$options = [
291-
'database' => 'my-app',
289+
'gcProbablity' => 0.001,
290+
'database' => 'myapp',
292291
'collection' => 'lock',
292+
'uriOptions' => [],
293+
'driverOptions' => [],
293294
];
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``:
294312

295-
$store = new MongoDbStore($client, $options);
313+
- ``$options['database']`` is ignored
314+
- ``$options['collection']`` is ignored
296315

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::
298327

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``.
308330

309331
.. _lock-store-pdo:
310332

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.