Connections to Couchbase while using the .NET SessionStateProvider


I am interested in using the custom .NET CouchbaseSessionStateProvider but I realized that, when initialized, the provider automatically connects to couchbase by creating a new client. For our project, we use a single CouchbaseClient instance to communicate with the server and were wondering if there would be any way to use our instance for the provider instead. It doesn’t seem possible currently, and I don’t know much about session-state store providers in .NET and how they get initialized so I’m not sure if it’s even possible at all, but I thought I’d ask.




Hi @pdavis,
The session and cache provider for uses ClusterHelper internally.

ClusterHelper is a Singleton class that you can use to get a shared and thread safe bucket instance. Therefore is you use ClusterHelper in you app to get a bucket instance, it will be shared for the entire app.

My guess is that if you replace your “new Cluster(…)” with “ClusterHelper.GetBucket(…)” then you will have only one instance.

We recommend using ClusterHelper in all your apps.

I hope this helps.