在 couchbase 中存储集群或存储桶实例是一个好习惯吗?

In couchbase is it a good practice to store the cluster or bucket instance?

可以按如下所示导出存储桶实例吗?

module.exports.bucket = (新couchbase.Cluster(config.couchbase.server)).openBucket(config.couchbase.bucket);

显然,我可以在我的应用程序的任何位置使用存储桶对象。但这会对性能产生影响吗?

文档说

A Couchbase SDK will also automatically adjust the port uses to communicate to the Couchbase Server based on any changes to cluster topology. Therefore it is not necessary to adjust your code for connecting to accommodate cluster rebalance, or to accommodate node addition or deletion.

这是否意味着我的代码很好?

是的,你应该很好,桶实例的初始化成本很高,因此应该重用(如 tuning section of the Node SDK doc 中所确认)。