Ce contenu n'est pas disponible dans la langue sélectionnée.
11.6. Hot Rod Java Client
11.6.1. Hot Rod Java Client Download Copier lienLien copié sur presse-papiers!
Procedure 11.1. Download Hot Rod Java Client
- Log into the Customer Portal at https://access.redhat.com.
- Click the button near the top of the page.
- In the Product Downloads page, click .
- Select the appropriate JBoss Data Grid version from the Version: drop down menu.
- Locate the Red Hat JBoss Data Grid ${VERSION} Hot Rod Java Client entry and click the corresponding link.
11.6.2. Hot Rod Java Client Configuration Copier lienLien copié sur presse-papiers!
Example 11.1. Client Instance Creation
To configure the Hot Rod Java client, edit the hotrod-client.properties file on the classpath.
hotrod-client.properties file.
Example 11.2. Configuration
Note
TCP KEEPALIVE configuration is enabled/disabled on the Hot Rod Java client either through a config property as seen in the example (infinispan.client.hotrod.tcp_keep_alive = true/false or programmatically through the org.infinispan.client.hotrod.ConfigurationBuilder.tcpKeepAlive() method.
new RemoteCacheManager(boolean start)new RemoteCacheManager()
11.6.3. Hot Rod Java Client Basic API Copier lienLien copié sur presse-papiers!
localhost:11222.
Example 11.3. Basic API
RemoteCacheManager corresponds to DefaultCacheManager, and both implement BasicCacheContainer.
DefaultCacheManager and RemoteCacheManager, which is simplified by the common BasicCacheContainer interface.
keySet() method. If the remote cache is a distributed cache, the server will start a Map/Reduce job to retrieve all keys from clustered nodes and return all keys to the client.
Set keys = remoteCache.keySet();
Set keys = remoteCache.keySet();
11.6.4. Hot Rod Java Client Versioned API Copier lienLien copié sur presse-papiers!
getVersioned, clients can retrieve the value associated with the key as well as the current version.
RemoteCacheManager provides instances of the RemoteCache interface that accesses the named or default cache on the remote cluster. This extends the Cache interface to which it adds new methods, including the versioned API.
Example 11.4. Using Versioned Methods
Example 11.5. Using Replace
remoteCache.put("car", "ferrari");
VersionedValue valueBinary = remoteCache.getVersioned("car");
assert remoteCache.replaceWithVersion("car", "lamborghini", valueBinary.getVersion());
remoteCache.put("car", "ferrari");
VersionedValue valueBinary = remoteCache.getVersioned("car");
assert remoteCache.replaceWithVersion("car", "lamborghini", valueBinary.getVersion());