feature #27648 [Lock] Added MongoDBStore (Joe Bennett)
This PR was merged into the 4.3-dev branch.
Discussion
----------
[Lock] Added MongoDBStore
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes (requires `ext-mongodb` and `mongodb/mongodb` to test)
| Fixed tickets | #27345
| License | MIT
| Doc PR | symfony/symfony-docs#9807
**Testing caveat**
In order to test this, the test environment needs `ext-mongodb` and `mongodb/mongodb`.
I have both written the test and tested `Symfony\Component\Lock\Store\MongoDbStore` and it does pass in an environment with `ext-mongodb` and `mongodb/mongodb`.
**Description**
We should support Semaphore Locks with a MongoDB back end to allow those that already use MongoDB as a distributed storage engine.
Symfony already partially supports MongoDB for session storage: `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler`
**Example**
```php
$client = new MongoDb\Client();
$store = new Symfony\Component\Lock\Store\MongoDbStore(
$client
array(
'database' => 'my-app',
)
);
$lockFactory = new Symfony\Component\Lock\Factory($store);
$lock = $lockFactory->createLock('my-resource');
```
This is a squashed pull request of https://github.com/symfony/symfony/pull/27346
Commits
-------
9c04639dc3
#27345 Added Lock/Store/MongoDbStore
This commit is contained in:
commit
c203379dd5
@ -19,6 +19,7 @@
|
||||
<env name="LDAP_PORT" value="3389" />
|
||||
<env name="REDIS_HOST" value="localhost" />
|
||||
<env name="MEMCACHED_HOST" value="localhost" />
|
||||
<env name="MONGODB_HOST" value="localhost" />
|
||||
<env name="ZOOKEEPER_HOST" value="localhost" />
|
||||
</php>
|
||||
|
||||
|
@ -20,8 +20,9 @@
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"predis/predis": "~1.0",
|
||||
"doctrine/dbal": "~2.4"
|
||||
"doctrine/dbal": "~2.4",
|
||||
"mongodb/mongodb": "~1.1",
|
||||
"predis/predis": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Lock\\": "" },
|
||||
|
@ -12,6 +12,7 @@
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<env name="REDIS_HOST" value="localhost" />
|
||||
<env name="MEMCACHED_HOST" value="localhost" />
|
||||
<env name="MONGODB_HOST" value="localhost" />
|
||||
<env name="ZOOKEEPER_HOST" value="localhost" />
|
||||
</php>
|
||||
|
||||
|
Reference in New Issue
Block a user