此内容没有您所选择的语言版本。
2.2. Creating CacheManagers
2.2.1. Create a New RemoteCacheManager 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Use the following configuration to configure a new
RemoteCacheManager:
import org.infinispan.client.hotrod.configuration.Configuration;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
Configuration conf = new
ConfigurationBuilder().addServer().host("localhost").port(11222).build();
RemoteCacheManager manager = new RemoteCacheManager(conf);
RemoteCache defaultCache = manager.getCache();
Configuration Explanation
An explanation of each line of the provided configuration is as follows:
- Use the
ConfigurationBuilder()method to configure a new builder. The.addServer()property adds a remote server, specified via the.host(<hostname|ip>)and.port(<port>)properties.Configuration conf = new ConfigurationBuilder().addServer().host(<hostname|ip>).port(<port>).build(); - Create a new
RemoteCacheManagerusing the supplied configuration.RemoteCacheManager manager = new RemoteCacheManager(conf); - Retrieve the default cache from the remote server.
RemoteCache defaultCache = manager.getCache();