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