Module: Couchbase::Operations::Store
- Defined in:
- lib/couchbase/operations/store.rb
Constant Summary collapse
- STORE_OP_METHODS =
{ set: -> client, key, value, ttl, transcoder { client.set(key, ttl.to_i, value, transcoder) }, add: -> client, key, value, ttl, transcoder { client.add(key, ttl.to_i, value, transcoder) }, replace: -> client, key, value, ttl, transcoder { client.replace(key, ttl.to_i, value, transcoder) }, append: -> client, key, value, ttl, transcoder { client.append(key, value, transcoder) }, prepend: -> client, key, value, ttl, transcoder { client.prepend(key, value, transcoder) } }.freeze
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.
- #async_add(key, value, options, &block) ⇒ Object
- #async_replace(key, value, options, &block) ⇒ Object
- #async_set(key, value, options = {}, &block) ⇒ 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
136 137 138 139 140 141 |
# File 'lib/couchbase/operations/store.rb', line 136 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
192 193 194 |
# File 'lib/couchbase/operations/store.rb', line 192 def add(key, value = nil, = {}) store_op(:add, key, value, ) 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
322 323 324 |
# File 'lib/couchbase/operations/store.rb', line 322 def append(key, value) store_op(:append, key, value) end |
#async_add(key, value, options, &block) ⇒ Object
196 197 198 |
# File 'lib/couchbase/operations/store.rb', line 196 def async_add(key, value, , &block) async_store_op(:add, key, value, , &block) end |
#async_replace(key, value, options, &block) ⇒ Object
245 246 247 |
# File 'lib/couchbase/operations/store.rb', line 245 def async_replace(key, value, , &block) async_store_op(:replace, key, value, , &block) end |
#async_set(key, value, options = {}, &block) ⇒ Object
132 133 134 |
# File 'lib/couchbase/operations/store.rb', line 132 def async_set(key, value, = {}, &block) async_store_op(:set, key, value, , &block) 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
378 379 380 |
# File 'lib/couchbase/operations/store.rb', line 378 def prepend(key, value) store_op(:prepend, key, value) end |
#replace(key, value, options = {}) ⇒ Fixnum
Replace the existing object in the database
241 242 243 |
# File 'lib/couchbase/operations/store.rb', line 241 def replace(key, value, = {}) store_op(:replace, key, value, ) end |
#set(key, value, options = {}) {|ret| ... } ⇒ Fixnum
Unconditionally store the object in the Couchbase
128 129 130 |
# File 'lib/couchbase/operations/store.rb', line 128 def set(key, value = nil, = {}) store_op(:set, key, value, ) end |