Chapter 3. Configuring the Hot Rod C++ client
Chapter 3. Configuring the Hot Rod C++ client Hot Rod C++ clients interact with remote Data Grid clusters via the RemoteCache API. 3.1. Configuration and Remote Cache Manager APIs Use the ConfigurationBuilder API to configure Hot Rod C++ client connections and the RemoteCacheManager API to obtain and configure remote caches. Configuration builder #include "infinispan/hotrod/ConfigurationBuilder.h" #include "infinispan/hotrod/RemoteCacheManager.h" #include <infinispan/hotrod/RemoteCache.h> #include <iostream> int main () { ConfigurationBuilder builder; // Configure a cache manager to connect with Hot Rod version 2.8 builder.protocolVersion(Configuration::PROTOCOL_VERSION_28); // Connect to a server at localhost with the default port. builder.addServer().host("127.0.0.1").port(11222); // Create and start a RemoteCacheManager to interact with caches. RemoteCacheManager cacheManager(builder.build(), false); cacheManager.start(); ... } Cross-site replication ConfigurationBuilder builder; builder.addServer().host("127.0.0.1").port(11222); // Configure a remote cluster and node when using cross-site replication. builder.addCluster("NYC").addClusterNode("192.0.2.0", 11322); Near caching ConfigurationBuilder builder; builder.addServer().host("127.0.0.1").port(11222); // Enable near-caching for the client. builder.nearCache().mode(NearCacheMode::INVALIDATED).maxEntries(4); Additional resources Hot Rod C++ client API
#include "infinispan/hotrod/ConfigurationBuilder.h" #include "infinispan/hotrod/RemoteCacheManager.h" #include <infinispan/hotrod/RemoteCache.h> #include <iostream> int main () { ConfigurationBuilder builder; // Configure a cache manager to connect with Hot Rod version 2.8 builder.protocolVersion(Configuration::PROTOCOL_VERSION_28); // Connect to a server at localhost with the default port. builder.addServer().host("127.0.0.1").port(11222); // Create and start a RemoteCacheManager to interact with caches. RemoteCacheManager cacheManager(builder.build(), false); cacheManager.start(); } ConfigurationBuilder builder; builder.addServer().host("127.0.0.1").port(11222); // Configure a remote cluster and node when using cross-site replication. builder.addCluster("NYC").addClusterNode("192.0.2.0", 11322); ConfigurationBuilder builder; builder.addServer().host("127.0.0.1").port(11222); // Enable near-caching for the client. builder.nearCache().mode(NearCacheMode::INVALIDATED).maxEntries(4);