Module: Couchbase::Operations::Touch
- Defined in:
- lib/couchbase/operations/touch.rb
Instance Method Summary collapse
- #async_touch(key, ttl, &block) ⇒ Object
-
#touch(*args) ⇒ Object
Update the expiry time of an item.
Instance Method Details
#async_touch(key, ttl, &block) ⇒ Object
99 100 101 |
# File 'lib/couchbase/operations/touch.rb', line 99 def async_touch(key, ttl, &block) register_future(client.touch(key, ttl), { op: :touch }, &block) end |
#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.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/couchbase/operations/touch.rb', line 84 def touch(*args) key, ttl, = (args) case key when String, Symbol success = client_touch(key, ttl) not_found_error(!success, ) success when Hash multi_touch_hash(key, ) when Array multi_touch_array(key, ) end end |