Couchbase
限定名称 | 类型 | 发布 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
安装依赖项
(使用 CB Enterprise 5.5.3 测试)
Couchbase 过程依赖于一个客户端库,该库不包含在 APOC Extended 库中。此依赖项包含在 apoc-couchbase-dependencies-5.26.1-all.jar 文件中,可以从 release 页面下载。下载该文件后,应将其放置在 plugins
目录中并重启 Neo4j 服务器。
或者,您可以从 Maven 仓库将 Couchbase Java SDK 和 Couchbase JVM Core IO 复制到 plugins
目录中。
用法
要与 Couchbase 交互,您可以将要连接的主机定义为过程的第一个参数(bucket 作为第二个参数,document_id 作为第三个参数)
CALL apoc.couchbase.get('couchbase://Administrator:password@localhost', 'default', 'artist:vincent_van_gogh')
否则,您可以像使用 MongoDB 一样使用配置属性。例如,您可以将以下属性添加到 apoc.conf 文件中:
apoc.couchbase.mykey.username=Administrator apoc.couchbase.mykey.password=password apoc.couchbase.mykey.uri=host1,host2,host3 // here you can define more than one hostname if you're using a cluster apoc.couchbase.mykey.port=8091 // the bootstrapHttpDirectPort (optional)
CALL apoc.couchbase.get('mykey', 'default', 'artist:vincent_van_gogh')
您还可以在 apoc.conf 中定义一些 CouchbaseEnvironment 参数:
apoc.couchbase.connectTimeout=<default=5000> apoc.couchbase.kvTimeout=<default=2500> apoc.couchbase.ioPoolSize=<default=3>
要获取这些配置参数的深入说明,请参阅官方 Couchbase 文档
配置参数
这些过程支持以下配置参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
collection |
String |
"_default" |
要使用的 collection。参见Scope and collections |
scope |
String |
"_default" |
要使用的 scope。参见Scope and collections |
compressionEnabled |
boolean |
true |
如果启用,客户端在将文档发送到 Couchbase Server 之前会对其进行压缩。详情参见here。 |
compressionMinSize |
Integer |
32 |
以字节为单位的大小。小于此大小的文档不会被压缩。 |
compressionMinRatio |
Double |
0.83 |
一个介于 0 和 1 之间的值。指定文档必须有多高的“可压缩性”,才能将压缩形式发送到服务器。 |
mutationTokensEnabled |
boolean |
true |
mutation tokens 允许增强的持久性要求以及高级 N1QL 查询功能。如果您不需要这些功能并希望避免相关的开销,请将此设置为 false。 |
retryStrategy |
Enum[FAILFAST, BESTEFFORT] |
BESTEFFORT |
客户端的默认重试策略。重试策略决定失败的操作是否应该重试。详情参见here。 |
transcoder |
Enum[DEFAULT, RAWJSON, RAWSTRING, RAWBINARY] |
DEFAULT |
负责将 KV 二进制包与 Java 对象之间进行转换的 transcoder。 |
connectTimeout |
Long |
null |
打开 Bucket 时使用的连接超时(毫秒)。如果为 null,将使用 |
kvTimeout |
Long |
null |
对特定 key 执行操作时使用的 Key/Value 默认超时(毫秒)。如果为 null,将使用 |
disconnectTimeout |
Long |
10000 |
Cluster 断开连接时使用的断开连接超时(毫秒) |
queryTimeout |
Long |
75000 |
所有 N1QL 查询操作中使用的查询超时(毫秒) |
analyticsTimeout |
Long |
75000 |
所有 Analytics 查询操作中使用的分析超时(毫秒)。 |
viewTimeout |
Long |
75000 |
视图操作中使用的视图超时(毫秒)。如果在请求期间发生节点故障,内部集群超时设置为 60 秒。 |
searchTimeout |
Long |
75000 |
所有 FTS 操作中使用的搜索超时 |
configPollInterval |
Long |
2500 |
客户端获取集群拓扑信息的间隔,以便主动检测变化。 |
idleHttpConnectionTimeout |
Long |
4500 |
HTTP 连接在关闭并从连接池中移除之前可以保持空闲的时间长度。不建议超过 50 秒,因为某些服务的服务器端空闲超时为 1 分钟。 |
enableTcpKeepAlives |
boolean |
true |
如果启用,客户端会定期向服务器发送 TCP keepalive,以防止防火墙和其他网络设备中断空闲的 TCP 连接。 |
tcpKeepAliveTime |
long |
60000 |
触发 TCP keepalive 的空闲时间。(如果 enableTcpKeepAlives 为 false,则此设置无效。) TODO |
enableDnsSrv |
boolean |
true |
从 DNS SRV 记录获取引导节点列表。 TODO |
networkResolution |
com.couchbase.client.core.env.NetworkResolution |
null |
网络解析。详情参见here。 |
trustCertificate |
boolean |
null |
如果非 null,则它是包含单个 X.509 证书的文件路径,在建立安全连接时作为证书颁发机构信任。如果存在,这将启用 Tls。详情参见here。 |
waitUntilReady |
Long |
null |
此方法将等待直到集群状态默认为“在线”,或者达到超时。 |