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.
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:
-
http://developer.couchbase.com/documentation/server/current/sdk/dotnet/managing-connections.html
-
This a long post, but towards the bottom there is some good information: SDK 2.0.0.1, Connection Pooling & Connection Timeouts - #7 by k_maynard
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