1a60501f5000da8e98d6eb2acc87f4c6cfda5290
[awesomized/libmemcached] / docs / source / libmemcached / memcached_append.rst
1 Appending or Prepending Data
2 ============================
3
4 SYNOPSIS
5 --------
6
7 #include <libmemcached-|libmemcached_version|/memcached.h>
8 Compile and link with -lmemcached
9
10 .. function:: memcached_return_t memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags)
11
12 .. function:: memcached_return_t memcached_append(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags)
13
14 .. function:: memcached_return_t memcached_prepend_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags)
15
16 .. function:: memcached_return_t memcached_append_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags)
17
18 DESCRIPTION
19 -----------
20
21 `memcached_prepend` and memcached_append are used to modify information on a
22 server. All methods take a ``key``, and ``key_length`` to store the object. Keys
23 are currently limited to 250 characters when using either a version of memcached
24 which is 1.4 or below, or when using the text protocol. You must supply both a
25 value and a length. Optionally you may test an expiration time for the object
26 and a 16 byte value (it is meant to be used as a bitmap). ``flags`` is a 4byte
27 space that is stored alongside of the main value. Many sub libraries make use of
28 this field, so in most cases users should avoid making use of it.
29
30 `memcached_prepend` places a segment of data before the last piece of data
31 stored. Currently expiration and key are not used in the server.
32
33 `memcached_append` places a segment of data at the end of the last piece of data
34 stored. Currently expiration and key are not used in the server.
35
36 `memcached_prepend_by_key` and `memcached_append_by_key` methods both behave in
37 a similar method as the non key methods. The difference is that they use their
38 group_key parameter to map objects to particular servers.
39
40 If you are looking for performance, `memcached_set` with non-blocking IO is the
41 fastest way to store data on the server.
42
43 All of the above functions are tested with the `MEMCACHED_BEHAVIOR_USE_UDP`
44 behavior enabled. However, when using these operations with this behavior on,
45 there are limits to the size of the payload being sent to the server. The
46 reason for these limits is that the Memcached Server does not allow
47 multi-datagram requests and the current server implementation sets a datagram
48 size to 1400 bytes. Due to protocol overhead, the actual limit of the user
49 supplied data is less than 1400 bytes and depends on the protocol in use as,
50 well as the operation being executed. When running with the binary protocol,
51 `MEMCACHED_BEHAVIOR_BINARY_PROTOCOL`, the size of the key,value, flags and
52 expiry combined may not exceed 1368 bytes. When running with the ASCII protocol,
53 the exact limit fluctuates depending on which function is being executed and
54 whether the function is a cas operation or not. For non-cas ASCII set
55 operations, there are at least 1335 bytes available to split among the key,
56 key_prefix, and value; for cas ASCII operations there are at least 1318 bytes
57 available to split among the key, key_prefix and value. If the total size of the
58 command, including overhead, exceeds 1400 bytes, a `MEMCACHED_WRITE_FAILURE`
59 will be returned.
60
61 RETURN VALUE
62 ------------
63
64 All methods return a value of type `memcached_return_t`. On success the value
65 will be `MEMCACHED_SUCCESS`.
66
67 Use `memcached_strerror` to translate this value to a printable string.
68
69 SEE ALSO
70 --------
71
72 .. only:: man
73
74 :manpage:`memcached(1)`
75 :manpage:`libmemcached(3)`
76 :manpage:`memcached_strerror(3)`
77 :manpage:`memcached_set(3)`
78 :manpage:`memcached_add(3)`
79 :manpage:`memcached_cas(3)`
80 :manpage:`memcached_replace(3)`
81
82 .. only:: html
83
84 * :manpage:`memcached(1)`
85 * :doc:`../libmemcached`
86 * :doc:`memcached_set`
87 * :doc:`memcached_cas`
88 * :doc:`memcached_strerror`