10.2.5. リモートキャッシュストア
リモートキャッシュストア RemoteStore
は、リモート Data Grid クラスターをストレージとして使用します。
RemoteStore
は Hot Rod プロトコルを使用して、リモート Data Grid クラスターと通信します。
以下の設定例では、RemoteStore
は、Data Grid サーバー "one" および "two" で mycache という名前のリモートキャッシュを使用します。
宣言型設定
<persistence> <remote-store xmlns="urn:infinispan:config:store:remote:10.1" cache="mycache" raw-values="true"> <remote-server host="one" port="12111" /> <remote-server host="two" /> <connection-pool max-active="10" exhausted-action="CREATE_NEW" /> <write-behind /> </remote-store> </persistence>
<persistence>
<remote-store xmlns="urn:infinispan:config:store:remote:10.1" cache="mycache" raw-values="true">
<remote-server host="one" port="12111" />
<remote-server host="two" />
<connection-pool max-active="10" exhausted-action="CREATE_NEW" />
<write-behind />
</remote-store>
</persistence>
プログラムによる設定
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();
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();
セグメンテーション
RemoteStore
はセグメンテーションをサポートし、セグメントごとにキーとエントリーを公開できるため、一括操作がより効率的になります。ただし、セグメンテーションは Data Grid Hot Rod プロトコルバージョン 2.3 以降で利用できます。
リモートキャッシュストアと Data Grid サーバーの間でセグメントとハッシュの数が同じであることを確認します。そうしないと、一括操作が正しい結果を返しません。