The touch() methods allow you to update
the expiration time on a given key. This can be useful for
situations where you want to prevent an item from expiring without
resetting the associated value. For example, for a session
database you might want to keep the session alive in the database
each time the user accesses a web page without explicitly updating
the session value, keeping the user's session active and
available.
| API Call | client.touch(key, expiry) | ||
| Asynchronous | yes | ||
| Description | Update the expiry time of an item | ||
| Returns | Future<Boolean> (
Asynchronous request value, as Boolean
) | ||
| Arguments | |||
String key | Document ID used to identify the value | ||
int expiry | Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch). | ||
The first form of the touch() provides a
simple key/expiry call to update the expiry time on a given key.
For example, to update the expiry time on a session for another 5
minutes:
OperationFuture<Boolean> touchOp = client.touch("sessionid",300);