Module: Couchbase::Operations::Touch
- Defined in:
- lib/couchbase/operations/touch.rb
Instance Method Summary collapse
-
#touch(*args, &block) ⇒ Object
Update the expiry time of an item.
Instance Method Details
#touch(key, options = {}) {|ret| ... } ⇒ true, false #touch(keys) {|ret| ... } ⇒ Hash
Update the expiry time of an item
The touch method 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.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/couchbase/operations/touch.rb', line 67 def touch(*args, &block) sync_block_error if !async? && block_given? key, = (args) if key.respond_to?(:to_hash) multi_touch_hash(key, ) elsif key.respond_to?(:to_ary) multi_touch_array(key, ) else if async? java_async_touch(key, [:ttl], &block) else success = java_touch(key, [:ttl]) not_found_error(!success, ) success end end end |