6.13. 远程缓存存储
远程缓存存储 RemoteStore,使用 Hot Rod 协议在 Data Grid 集群上存储数据。
注意
如果将远程缓存存储配置为共享,则无法预加载数据。换句话说,如果在配置中 shared="true",那么您必须设置 preload="false "。
分段
RemoteStore 支持分段,并可按网段发布密钥和条目,从而提高了批量操作的效率。但是,分段仅通过 Data Grid Hot Rod 协议版本 2.3 或更高版本提供。
警告
当您为 RemoteStore 启用分段时,它使用您在 Data Grid 服务器配置中定义的片段数量。
如果源缓存被分段并使用与 RemoteStore 不同的片段,则会为批量操作返回不正确的值。在这种情况下,您应该禁用 RemoteStore 的分段。
远程缓存存储配置
XML
<distributed-cache>
<persistence>
<remote-store xmlns="urn:infinispan:config:store:remote:13.0"
cache="mycache"
raw-values="true">
<remote-server host="one"
port="12111" />
<remote-server host="two" />
<connection-pool max-active="10"
exhausted-action="CREATE_NEW" />
</remote-store>
</persistence>
</distributed-cache>
JSON
{
"distributed-cache": {
"remote-store": {
"cache": "mycache",
"raw-values": "true",
"remote-server": [
{
"host": "one",
"port": "12111"
},
{
"host": "two"
}
],
"connection-pool": {
"max-active": "10",
"exhausted-action": "CREATE_NEW"
}
}
}
}
YAML
distributedCache:
remoteStore:
cache: "mycache"
rawValues: "true"
remoteServer:
- host: "one"
port: "12111"
- host: "two"
connectionPool:
maxActive: "10"
exhaustedAction: "CREATE_NEW"
ConfigurationBuilder
ConfigurationBuilder b = new ConfigurationBuilder();
b.persistence().addStore(RemoteStoreConfigurationBuilder.class)
.fetchPersistentState(false)
.ignoreModifications(false)
.purgeOnStartup(false)
.remoteCacheName("mycache")
.rawValues(true)
.addServer()
.host("one").port(12111)
.addServer()
.host("two")
.connectionPool()
.maxActive(10)
.exhaustedAction(ExhaustedAction.CREATE_NEW)
.async().enable();