Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Enable setting cache option when defining CouchDB connection #4

Merged
merged 1 commit into from about 2 years ago

2 participants

Fadrizul H. garren smith
Fadrizul H.

This is essential for scaling out, and starting node is clustered mode.

By default cradle's caching is set to 'true'; if a PUT request is executed in one node and then the same request happens in another node instance. This will cause CouchDB to throw an error because of conflicting revisions, the model didn't get updated in the second instance because the update happened in the first one.

Setting cache to false and adding another HEAD request fixes this. :)

garren smith
Owner

Thanks merged

garren smith garrensmith merged commit edf609a into from March 26, 2012
garren smith garrensmith closed this March 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 26, 2012
Fadrizul H. Enable setting cache option when defining CouchDB conenction bc1adfc
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 8 deletions. Show diff stats Hide diff stats

  1. 14  lib/connection.js
14  lib/connection.js
@@ -4,25 +4,23 @@ var cradle = require('cradle'),
4 4
 
5 5
 module.exports.create_connection = function (options) {
6 6
   if (typeof(options) === 'string') {
7  
-    logger.info("Connecting to %s",options);   
  7
+    logger.info("Connecting to %s",options);
8 8
     db = new (cradle.Connection)().database(options);
9  
-  
  9
+
10 10
     return db;
11  
-  }  
12  
-  
  11
+  }
  12
+
13 13
   var _options = {},
14 14
       db_name = options.db,
15 15
       url = options.url,
16 16
       port = options.port;
17 17
 
18 18
   _options.secure = options.secure || false;
19  
-  _options.auth = options.auth;
  19
+  _options.auth   = options.auth;
  20
+  _options.cache  = options.cache === false ?  false : true;
20 21
 
21  
-  
22  
-    
23 22
   db = new (cradle.Connection)(url,port, _options).database(db_name);
24 23
 
25  
-
26 24
   return db;
27 25
 };
28 26
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.