6.13. 远程缓存存储


远程缓存存储 RemoteStore 使用 Hot Rod 协议在 Data Grid 集群上存储数据。

注意

如果您将远程缓存存储配置为共享,则无法预加载数据。在您的配置中为 shared="true" 换句话说,您必须设置 preload="false"

共享远程缓存容器

每个远程缓存存储都会创建一个专用的远程缓存管理器。如果有多个远程存储连接到同一服务器,则这会浪费资源。使用 remote-cache-containers 配置创建共享远程缓存管理器,并使用 remote-store 定义中的名称来引用它们。

提示

如果只有一个 remote-cache-container,则默认在所有远程缓存存储中使用它,但不明确指定一个。

分段

RemoteStore 支持分段,并可按网段发布密钥和证书,从而使批量操作更高效。但是,分段仅适用于 Data Grid Hot Rod 协议版本 2.3 或更高版本。

警告

当您为 RemoteStore 启用分段时,会使用您在 Data Grid 服务器配置中定义的片段数量。

如果源缓存被分段并使用与 RemoteStore 不同的片段数,则为批量操作返回不正确的值。在这种情况下,您应该禁用 RemoteStore 的分段。

使用共享远程容器的远程缓存存储配置

XML

<infinispan>

    <remote-cache-containers>
        <remote-cache-container uri="hotrod://one,two:12111?max-active=10&amp;exhausted-action=CREATE_NEW"/>
    </remote-cache-containers>

    <cache-container>
        <distributed-cache>
            <persistence>
                <remote-store xmlns="urn:infinispan:config:store:remote:15.0"
                              cache="mycache"
                              raw-values="true"
                />
            </persistence>
        </distributed-cache>
    </cache-container>
</infinispan>
Copy to Clipboard Toggle word wrap

JSON

{
  "infinispan": {
    "remote-cache-containers": [
      {
        "uri": "hotrod://one,two:12111?max-active=10&exhausted-action=CREATE_NEW"
      }
    ],
    "cache-container": {
      "caches": {
        "mycache": {
          "distributed-cache": {
            "remote-store": {
              "cache": "mycache",
              "raw-values": "true"
            }
          }
        }
      }
    }
  }
}
Copy to Clipboard Toggle word wrap

YAML

infinispan:
  remoteCacheContainers:
    - uri: "hotrod://one,two:12111?max-active=10&exhausted-action=CREATE_NEW"
  cacheContainer:
    caches:
      mycache:
        distributedCache:
          remoteStore:
            cache: "mycache"
            rawValues: "true"
            remoteServer:
              - host: "one"
                port: "12111"
              - host: "two"
            connectionPool:
              maxActive: "10"
              exhaustedAction: "CREATE_NEW"
Copy to Clipboard Toggle word wrap

ConfigurationBuilder

ConfigurationBuilder b = new ConfigurationBuilder();
b.persistence().addStore(RemoteStoreConfigurationBuilder.class)
      .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();
Copy to Clipboard Toggle word wrap

使用私有远程容器的远程缓存存储配置

XML

<distributed-cache>
  <persistence>
    <remote-store xmlns="urn:infinispan:config:store:remote:15.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>
Copy to Clipboard Toggle word wrap

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"
      }
    }
  }
}
Copy to Clipboard Toggle word wrap

YAML

distributedCache:
  remoteStore:
    cache: "mycache"
    rawValues: "true"
    remoteServer:
      - host: "one"
        port: "12111"
      - host: "two"
    connectionPool:
      maxActive: "10"
      exhaustedAction: "CREATE_NEW"
Copy to Clipboard Toggle word wrap

ConfigurationBuilder

ConfigurationBuilder b = new ConfigurationBuilder();
b.persistence().addStore(RemoteStoreConfigurationBuilder.class)
      .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();
Copy to Clipboard Toggle word wrap

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat