The Get-and-Touch (GAT) methods obtain a value for a given key and update the expiry time for the key. This can be useful for session values and other information where you want to set an expiry time, but don't want the value to expire while the value is still in use.
| API Call | client.getAndTouch(key, expiry) | ||
| Asynchronous | no | ||
| Description | Get a value and update the expiration time for a given key | ||
| Introduced Version | 1.0 | ||
| Returns | CASValue (
Check and set object
) | ||
| 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 getAndTouch()
obtains a given value and updates the expiry time. For example, to
get session data and renew the expiry time to five minutes:
session = membase.getAndTouch('sessionid',300);| API Call | client.getAndTouch(key, expiry, transcoder) | ||
| Asynchronous | no | ||
| Description | Get a value and update the expiration time for a given key | ||
| Introduced Version | 1.0 | ||
| Returns | CASValue (
Check and set object
) | ||
| 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). | ||
Transcoder<T> transcoder | Transcoder class to be used to serialize value | ||
The second form supports the use of a custom transcoder for the stored value information.
| API Call | client.asyncGetAndTouch(key, expiry) | ||
| Asynchronous | yes | ||
| Description | Get a value and update the expiration time for a given key | ||
| Introduced Version | 1.0 | ||
| Returns | Future<CASValue<Object>> (
Asynchronous request value, as CASValue, as Object
) | ||
| 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 asynchronous methods obtain the value and update the expiry time without requiring you to actively wait for the response. The returned value is a CAS object with the embedded value object.
Future<CASResponse<Object>> future = membase.asyncGetAndTouch("sessionid", 300); CASResponse<Object> casr; try { casr = future.get(5, TimeUnit.SECONDS); } catch(TimeoutException e) { future.cancel(false); }
| API Call | client.asyncGetAndTouch(key, expiry, transcoder) | ||
| Asynchronous | yes | ||
| Description | Get a value and update the expiration time for a given key | ||
| Introduced Version | 1.0 | ||
| Returns | Future<CASValue<T>> (
Asynchronous request value, as CASValue as Transcoded object
) | ||
| 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). | ||
Transcoder<T> transcoder | Transcoder class to be used to serialize value | ||
The second form of the asynchronous method supports the use of a custom transcoder for the stored object.