Use singleton or not, it is a good idea

I’m using .net sdk and I wonder which is better to have a sigleton , or open and to dispose of the cluster and bucket each time you make a read and write operation , taking into consideration that the application is multi thread.

@jrtaveras -

I suggest you use the ClusterHelper class and initialize when the app starts up and close it when the app shuts down. Here are some useful links:

The reason you do not want to open/close a bucket on every use is because of the overhead associated with creating the TCP connections, bootstrapping and finally authenticating each connection. The ClusterHelper will create a singleton out of the Cluster object and then cache each bucket instance and reuse them over and over.

-Jeff

Muchas Gracias,
Thanks