11.9.4. Hot Rod Java Client Versioned API
To ensure data consistency, Hot Rod stores a version number that uniquely identifies each modification. Using a
getVersioned or getWithVersion, clients can retrieve the value associated with the key as well as the current version.
When using the Hot Rod Java client, a
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.
The following example shows the usage of versioned methods:
Similarly for replace:
remoteCache.put("car", "ferrari");
RemoteCache.VersionedValue valueBinary = remoteCache.getVersioned("car");
assert remoteCache.replace("car", "lamborghini", valueBinary.getVersion());
remoteCache.put("car", "ferrari");
RemoteCache.VersionedValue valueBinary = remoteCache.getVersioned("car");
assert remoteCache.replace("car", "lamborghini", valueBinary.getVersion());