Method: Couchbase::Collection#touch

Defined in:
lib/couchbase/collection.rb

#touch(id, expiry, options = Options::Touch::DEFAULT) ⇒ MutationResult

Update the expiration of the document with the given id

Examples:

Reset expiration timer for document to 30 seconds

res = collection.touch("customer123", 30)

Parameters:

  • id (String)

    the document id which is used to uniquely identify it.

  • expiry (Integer, #in_seconds, Time)

    new expiration time for the document

  • options (Options::Touch) (defaults to: Options::Touch::DEFAULT)

    request customization

Returns:



422
423
424
425
426
427
428
429
# File 'lib/couchbase/collection.rb', line 422

def touch(id, expiry, options = Options::Touch::DEFAULT)
  resp = @backend.document_touch(bucket_name, @scope_name, @name, id,
                                 Utils::Time.extract_expiry_time(expiry),
                                 options.to_backend)
  MutationResult.new do |res|
    res.cas = resp[:cas]
  end
end