[id='hotrod_return_values']
= Forcing Return Values
To avoid sending data unnecessarily, write operations on remote caches return
`null` instead of previous values.

For example, the following method calls do not return previous values for keys:

[source,java]
----
V remove(Object key);
V put(K key, V value);
----

You can change this default behavior with the `FORCE_RETURN_VALUE` flag so your
invocations return previous values.

.Procedure

* Use the `FORCE_RETURN_VALUE` flag to get previous values instead of `null` as
in the following example:

[source,java]
----
cache.put("aKey", "initialValue");
assert null == cache.put("aKey", "aValue");
assert "aValue".equals(cache.withFlags(Flag.FORCE_RETURN_VALUE).put("aKey",
   "newValue"));
----

.Reference

link:{javadocroot}/org/infinispan/client/hotrod/Flag.html#FORCE_RETURN_VALUE[org.infinispan.client.hotrod.Flag]
