Module: Couchbase::Operations::Store
- Defined in:
- lib/couchbase/operations/store.rb
Instance Method Summary collapse
- #[]=(key, *args) ⇒ Object
-
#add(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Add the item to the database, but fail if the object exists already.
-
#append(key, value, options = {}) ⇒ Fixnum
Append this object to the existing object.
-
#prepend(key, value, options = {}) ⇒ Object
Prepend this object to the existing object.
-
#replace(key, value, options = {}) ⇒ Fixnum
Replace the existing object in the database.
-
#set(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Unconditionally store the object in the Couchbase.
Instance Method Details
#[]=(key, *args) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/couchbase/operations/store.rb', line 108 def []=(key, *args) = args.size > 1 ? args.shift : {} value = args.pop set(key, value, ) end |
#add(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Add the item to the database, but fail if the object exists already
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/couchbase/operations/store.rb', line 164 def add(key, value = nil, = {}, &block) sync_block_error if !async? && block_given? op, key, value, ttl = store_args_parser(key, value, ) if op == :single add_single(key, value, ttl, , &block) else add_multi(key) end end |
#append(key, value, options = {}) ⇒ Fixnum
This operation is kind of data-aware from server point of view.
This mean that the server treats value as binary stream and just
perform concatenation, therefore it won't work with :marshal and
:document formats, because of lack of knowledge how to merge values
in these formats. See Bucket#cas for workaround.
Append this object to the existing object
298 299 300 301 302 303 304 305 |
# File 'lib/couchbase/operations/store.rb', line 298 def append(key, value) sync_block_error if !async? && block_given? if cas = java_append(validate_key(key), value) cas else raise Couchbase::Error::NotFound.new end end |
#prepend(key, value, options = {}) ⇒ Object
This operation is kind of data-aware from server point of view.
This mean that the server treats value as binary stream and just
perform concatenation, therefore it won't work with :marshal and
:document formats, because of lack of knowledge how to merge values
in these formats. See Bucket#cas for workaround.
Prepend this object to the existing object
359 360 361 |
# File 'lib/couchbase/operations/store.rb', line 359 def prepend(*args) sync_block_error if !async? && block_given? end |
#replace(key, value, options = {}) ⇒ Fixnum
Replace the existing object in the database
216 217 218 219 220 221 222 223 |
# File 'lib/couchbase/operations/store.rb', line 216 def replace(key, value, = {}) sync_block_error if !async? && block_given? if cas = java_replace(key, value, [:ttl]) cas else raise Couchbase::Error::NotFound.new end end |
#set(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Unconditionally store the object in the Couchbase
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/couchbase/operations/store.rb', line 97 def set(key, value = nil, = {}, &block) sync_block_error if !async? && block_given? op, key, value, ttl = store_args_parser(key, value, ) if op == :single set_single(key, value, ttl, , &block) else set_multi(key) end end |