The append() methods allow you to add
information to an existing key/value pair in the database. You can
use this to add information to a string or other data after the
existing data.
The append() methods append raw
serialized data on to the end of the existing data in the key. If
you have previously stored a serialized object into Membase and
then use append, the content of the serialized object will not be
extended. For example, adding Dictionary of
integers into the database, and then using
append() to add another integer will
result in the key referring to a serialized version of the
dictionary, immediately followed by a serialized version of the
integer. It will not contain an updated dictionary with the new
integer appended to it. De-serialization of objects that have had
data appended may result in data corruption.
| API Call | object.append(key, value [, casunique ]) | ||
| Asynchronous | no | ||
| Description | Append a value to an existing key | ||
| Returns | object (
Binary object
) | ||
| Arguments | |||
key | Document ID used to identify the value | ||
object value | Value to be stored | ||
int casunique | Unique value used to verify a key/value combination | ||
The append() appends information to the
end of an existing key/value pair. The
append() function requires a CAS value.
For example, to append a string to an existing key, first get the value for the given key, then use the first element in the returned list as the CAS:
casv = membase.get("samplekey") membase.append(casv[0],"samplekey", "appendedstring")