我已经安装了 couchbase 1.8 并使用了 couchbase .net 客户端库。 是否按照以下文档中给出的所有配置进行了配置,但 client.store 总是失败并返回 false。
<configSections>
<section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
</configSections>
<couchbase>
<servers bucket="default" bucketPassword="">
<add uri="http://xx.xx.xx.xx:8091/pools/default"/>
</servers>
</couchbase>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
CouchbaseClient client = new CouchbaseClient(); //this creates a not null client object
bool result = client.store(Storemode.Add,"test","Couchbase test"); // this returns false always
string str = client.Get("test") as string; // this returns null always
我可以远程登录到 8091 端口。 telnet 进入空白屏幕,键入任何键都会从 telnet session 中出来,说客户端发送了错误的请求。我猜这是正确的行为,但不知何故商店失败了。我在 couchbase 默认数据库上没有看到任何事件。
感谢任何帮助。
请您参考如下方法:
您的配置看起来正确。但是,如果您之前为键“test”保存了一个非字符串值,那么您的代码将对结果产生 false,对字符串产生 null。
StoreMode.Add 将对给定键的 Store 操作工作一次且仅一次。因此,如果您之前为键“test”保存了一个 int,那么 Store 将失败。并且 as 转换也将返回 null。
如果您尝试 StoreMode.Set,代码是否正常运行?
