Configuring the connection programmatically:
var config = new ClientConfiguration
{
Servers = new List<Uri> {
new Uri("http://localhost:8091/pools")
},
BucketConfigs = new Dictionary<string, BucketConfiguration>
{
{ "default", new BucketConfiguration
{
BucketName = "default",
UseSsl = false,
Password = "",
DefaultOperationLifespan = 2000,
PoolConfiguration = new PoolConfiguration
{
MaxSize = 10,
MinSize = 5,
SendTimeout = 12000
}
}}
}
};
var cluster = new Cluster(config);
var bucket = cluster.OpenBucket();
Configuring the connection in web.config
/ app.config
:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="couchbaseClients">
<section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" />
</sectionGroup>
</configSections>
<couchbaseClients>
<couchbase useSsl="false">
<servers>
<add uri="http://localhost:8091/pools"></add>
</servers>
<buckets>
<add name="default" useSsl="false" password="">
<connectionPool name="custom" maxSize="10" minSize="5" sendTimeout="12000" />
</add>
</buckets>
</couchbase>
</couchbaseClients>
</configuration>
Using the config section:
var cluster = new Cluster("couchbaseClients/couchbase");
var bucket = cluster.OpenBucket();