module Couchbase::Operations::Unlock
Public Instance Methods
async_unlock(key, options = {})
click to toggle source
# File lib/couchbase/operations/unlock.rb, line 84 def async_unlock(key, options = {}) end
unlock(key, options = {})
click to toggle source
Unlock
key
@since 1.2.0
The unlock
method allow you to unlock key once locked by {Bucket#get} with :lock
option.
@overload unlock(key, options = {})
@param key [String, Symbol] Key used to reference the value. @param options [Hash] Options for operation. @option options [Fixnum] :cas The CAS value must match the current one from the storage. @option options [true, false] :quiet (self.quiet) If set to +true+, the operation won't raise error for missing key, it will return +nil+. @return [true, false] +true+ if the operation was successful and +false+ otherwise. @raise [Couchbase::Error::Connect] if connection closed (see {Bucket#reconnect}) @raise [ArgumentError] when passing the block in synchronous mode @raise [Couchbase::Error::NotFound] if key(s) not found in the storage @raise [Couchbase::Error::TemporaryFail] if either the key wasn't locked or given CAS value doesn't match to actual in the storage @example Unlock the single key val, _, cas = c.get("foo", :lock => true, :extended => true) c.unlock("foo", :cas => cas)
@overload unlock(keys)
@param keys [Hash] The Hash where keys represent the keys in the database, values -- the CAS for corresponding key. @yieldparam ret [Result] the result of operation for each key in asynchronous mode (valid attributes: +error+, +operation+, +key+). @return [Hash] Mapping keys to result of unlock operation (+true+ if the operation was successful and +false+ otherwise) @example Unlock several keys c.unlock("foo" => cas1, :bar => cas2) #=> {"foo" => true, "bar" => true} @example Unlock several values in async mode c.run do c.unlock("foo" => 10, :bar => 20) do |ret| ret.operation #=> :unlock ret.success? #=> true ret.key #=> "foo" and "bar" in separate calls end end
# File lib/couchbase/operations/unlock.rb, line 75 def unlock(key, options = {}) cas = options.respond_to?(:to_hash) ? options[:cas] : options if client.unlock(key.to_s, cas) true else raise Couchbase::Error::TemporaryFail.new end end