8000 feature #27648 [Lock] Added MongoDBStore (Joe Bennett) · symfony/symfony@c203379 · GitHub
[go: up one dir, main page]

Skip to content

Commit c203379

Browse files
committed
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 #27346 Commits ------- 9c04639 #27345 Added Lock/Store/MongoDbStore
2 parents 37b616f + 9c04639 commit c203379

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<env name="LDAP_PORT" value="3389" />
2020
<env name="REDIS_HOST" value="localhost" />
2121
<env name="MEMCACHED_HOST" value="localhost" />
22+
<env name="MONGODB_HOST" value="localhost" />
2223
<env name="ZOOKEEPER_HOST" value="localhost" />
2324
</php>
2425

src/Symfony/Component/Lock/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"psr/log": "~1.0"
2121
},
2222
"require-dev": {
23-
"predis/predis": "~1.0",
24-
"doctrine/dbal": "~2.4"
23+
"doctrine/dbal": "~2.4",
24+
"mongodb/mongodb": "~1.1",
25+
"predis/predis": "~1.0"
2526
},
2627
"autoload": {
2728
"psr-4": { "Symfony\\Component\\Lock\\": "" },

src/Symfony/Component/Lock/phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ini name="error_reporting" value="-1" />
1313
<env name="REDIS_HOST" value="localhost" />
1414
<env name="MEMCACHED_HOST" value="localhost" />
15+
<env name="MONGODB_HOST" value="localhost" />
1516
<env name="ZOOKEEPER_HOST" value="localhost" />
1617
</php>
1718

0 commit comments

Comments
 (0)
0