Several Couchbase bucket configurations in .NET.

I have two buckets in Couchbase, one of which is the Couchbase type, and the other is the Memcachced type: when I run my test, I get an error: element servers can only appear once in this section. Below is my configuration:

  <couchbase>
    <servers bucket="RepositoryCache" bucketPassword="">
      <add uri="http://127.0.0.1:8091/pools/default"/>
    </servers>

    <servers bucket="default" bucketPassword="">
      <add uri="http://127.0.0.1:8091/pools/default"/>
    </servers>
  </couchbase>

 How to configure multiple buckets and resolve the issue? I hv read the manual and I could not find much help.
+5
source share
4 answers

From the documentation , it looks like you can do it like this:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="couchbase">
      <section name="bucket-a" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
      <section name="bucket-b" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
    </sectionGroup>
  </configSections>

  <couchbase>
    <bucket-a>
      <servers bucket="default">
        <add uri="http://127.0.0.1:8091/pools" />
      </servers>
    </bucket-a>
    <bucket-b>
      <servers bucket="beernique" bucketPassword="b33rs">
        <add uri="http://127.0.0.1:8091/pools" />
      </servers>
    </bucket-b>
  </couchbase>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>
+1
source

I asked this question earlier on several Couchbase buckets in the .NET app.config , but no one answered.

couchbase.net ClientConfigurationSection "couchbase" .

, "default", . . XML , , .

0

.

CouchbaseClient bucketname . : var client = new CouchbaseClient ( "default", "");

bucket web.cong.

0

If you want to continue to use the App | Web.config, you can also simply create a second configuration section as follows:

<section name="otherconfig" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>

<otherconfig>
    <servers bucket="default" bucketPassword="">
      <add uri="http://127.0.0.1:8091/pools"/>
    </servers>
  </otherconfig>

var client = new CouchbaseClient((CouchbaseClientSection)ConfigurationManager.GetSection("otherconfig"));
0
source

All Articles