CouchBase 3.0 Closing Connection .disconnect() shutdown()

HI there:

I’m looking for your advise in order to know where is the best time or best place to close the connection and what it’s the difference between disconect() and shutdown.

This is a code example:

var couchbase = require(‘couchbase’);
var cluster = new couchbase.Cluster();
var bucket = cluster.openBucket(‘default’);

bucket.upsert(‘testdoc’, {name:‘Frank’}, function(err, result) {
if (err) throw err;

bucket.get(‘testdoc’, function(err, result) {
if (err) throw err;

console.log(result.value);
// {name: Frank}

bucket.disconnect(); // Close connection
});
});

Hey Jorge,

You will want to disconnect the bucket ones you are certain there will not be any further operations being performed (a disconnected bucket cannot perform operations). Additionally, disconnect is the 2.0 method to use, the shutdown method is from the old SDK.

Cheers, Brett

Hi Brett:

Thanks for your prompt response, I underestand now.

Cheers,

Jorge

from what you said I think there is never need to close a bucket in a Node.js app, because a server app that is running and listening on a specific port it is always ready to do operations on bucket.
Am I write?