Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: .NET (C#) 1.0
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
7 Update Operations
Chapter Sections
Chapters

7.6. Touch Methods

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 Callobject.Touch(key, expiry)
Asynchronousno
Description Update the expiry time of an item
ReturnsBoolean ( 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));