Skip to content

Instantly share code, notes, and snippets.

@bryanhirsch
Created September 4, 2012 20:40
Show Gist options
  • Save bryanhirsch/3626207 to your computer and use it in GitHub Desktop.
Save bryanhirsch/3626207 to your computer and use it in GitHub Desktop.
Use persistent database connection by default.
diff --git a/mongodb.module b/mongodb.module
index c5e4afa..35b4527 100644
--- a/mongodb.module
+++ b/mongodb.module
@@ -31,6 +31,9 @@ function mongodb($alias = 'default') {
$db = $connection['db'];
if (!isset($mongo_objects[$host][$db])) {
try {
+ $options = variable_get('mongodb_options', array()) + array(
+ 'persist' => '1', // Use persistent connection by default.
+ );
$mongo = new Mongo($host, $options);
$mongo_objects[$host][$db] = $mongo->selectDB($db);
$mongo_objects[$host][$db]->connection = $mongo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment