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