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 | object.Touch(key, expiry) | ||
| Asynchronous | no | ||
| Description | Update the expiry time of an item | ||
| Returns | Boolean (
Boolean (true/false)
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object expiry | Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch). | ||
The Touch method 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 60 seconds:
client.Touch("session", TimeSpan.FromSeconds(60));To update the expiry time on the session for another day:
client.Touch("session", DateTime.Now.AddDays(1));