Best Practice with conection and Buckets


Is there any docs which describe what best practice would be on how to handle connections with the .net SDK
I have no problem connecting to server and open buckets but i want to make sure i am doing it the most effective

So based on what i read its recommended to create a ClusterHelper at start of App and close it at end of app ?
Is there a way to check if the clusterhelper exists and is initialized ? How about buckets, should they also be left
open or is it better to close them after i executed my code waiting for next one. If so whats the best way to check
if bucket is still avail ?

would be nice if there is a function something like ClusterHelper.Status or so as well as bucket(“name”).Status to help manage those connection and buckets most effectively



Yes, you should make a single connection to the cluster at startup and reuse it. ClusterHelper is a great way to do this.

Unfortunately, there isn’t a great way to tell if it’s initialized or not. You can call GetBucket() and trap the InitializationException, but this seems a big messy. I agree having an easy way to test this would be nice, I filed an issue to track this idea, In the meantime, I’d recommend keeping your own boolean to track if you initialized or not.

Yes, buckets should definitely be left open for the lifetime of the cluster. While they implement Dispose(), you shouldn’t call it. Instead, just use ClusterHelper.Close when you’re done with your app, it cleans up the buckets for you. Buckets are reentrant, so you can use them simultaneously in as many threads as you like. Note, however, that priority to SDK 2.4 you might need to increase the size of your connection pool if you have lots of threads accessing them simultaneously. After SDK 2.4 the connection is multiplexed so it shouldn’t be an issue.



Thanks, i thought so, the boolean is how i am doing it right now but its not that great, but will have to do. Hopefully they will implement a .status or .isinitialized function to be able to simply check.