1MEMCACHED_ADD_BY_KEY(3)      libmemcached-awesome      MEMCACHED_ADD_BY_KEY(3)
2
3
4

NAME

6       memcached_add_by_key - Storing and Replacing Data
7

SYNOPSIS

9       #include <libmemcached/memcached.h>
10              Compile and link with -lmemcached
11
12       memcached_return_t  memcached_set(memcached_st  *ptr,  const char *key,
13       size_t key_length, const char *value, size_t value_length, time_t expi‐
14       ration, uint32_t flags)
15
16       memcached_return_t  memcached_add(memcached_st  *ptr,  const char *key,
17       size_t key_length, const char *value, size_t value_length, time_t expi‐
18       ration, uint32_t flags)
19
20       memcached_return_t   memcached_replace(memcached_st  *ptr,  const  char
21       *key, size_t key_length, const char *value, size_t value_length, time_t
22       expiration, uint32_t flags)
23
24       memcached_return_t  memcached_set_by_key(memcached_st  *ptr, const char
25       *group_key,  size_t   group_key_length,   const   char   *key,   size_t
26       key_length,  const char *value, size_t value_length, time_t expiration,
27       uint32_t flags)
28
29       memcached_return_t memcached_add_by_key(memcached_st *ptr,  const  char
30       *group_key,   size_t   group_key_length,   const   char   *key,  size_t
31       key_length, const char *value, size_t value_length, time_t  expiration,
32       uint32_t flags)
33
34       memcached_return_t  memcached_replace_by_key(memcached_st  *ptr,  const
35       char *group_key,  size_t  group_key_length,  const  char  *key,  size_t
36       key_length,  const char *value, size_t value_length, time_t expiration,
37       uint32_t flags)
38

DESCRIPTION

40       memcached_set(), memcached_add(), and memcached_replace() are all  used
41       to  store  information  on  the server. All methods take a key, and its
42       length to store the object. Keys are currently limited to  250  charac‐
43       ters when using either a version of memcached(1) which is 1.4 or below,
44       or when using the text protocol. You must supply both  a  value  and  a
45       length.  Optionally you store the object. Keys are currently limited to
46       250 characters by the memcached(1) server. You must supply both a value
47       and a length. Optionally you may test an expiration time for the object
48       and a 16 byte value (it is meant to be used as a bitmap). "flags" is  a
49       4byte  space  that  is stored alongside of the main value. Many sub li‐
50       braries make use of this field, so in most  cases  users  should  avoid
51       making use of it.
52
53       memcached_set()  will  write  an object to the server. If an object al‐
54       ready exists it will overwrite what is in the  server.  If  the  object
55       does  not  exist  it will be written. If you are using the non-blocking
56       mode this function will always return true unless a network  error  oc‐
57       curs.
58
59       memcached_replace()  replaces an object on the server. If the object is
60       not found on the server an error occurs.
61
62       memcached_add() adds an object to the server. If the object is found on
63       the server an error occurs, otherwise the value is stored.
64
65       memcached_set_by_key(),           memcached_add_by_key(),           and
66       memcached_replace_by_key() methods all behave in a  similar  method  as
67       the  non  key  methods. The difference is that they use their group_key
68       parameter to map objects to particular servers.
69
70       If you are looking for performance, memcached_set()  with  non-blocking
71       IO is the fastest way to store data on the server.
72
73       All  of  the  above  functions  are  tested  with  the MEMCACHED_BEHAV‐
74       IOR_USE_UDP behavior enabled. However, when using these operations with
75       this  behavior  on,  there  are limits to the size of the payload being
76       sent to the server.  The reason for these limits is that the  Memcached
77       Server  does  not  allow multi-datagram requests and the current server
78       implementation sets a datagram size to  1400  bytes.  Due  to  protocol
79       overhead,  the actual limit of the user supplied data is less than 1400
80       bytes and depends on the protocol in use, as well as the operation  be‐
81       ing  executed.  When running with the binary protocol, MEMCACHED_BEHAV‐
82       IOR_BINARY_PROTOCOL, the size of the key,value, flags and  expiry  com‐
83       bined  may not exceed 1368 bytes. When running with the ASCII protocol,
84       the exact limit fluctuates depending on which function  is  being  exe‐
85       cuted  and  whether the function is a cas operation or not. For non-cas
86       ASCII set operations, there are at least 1335 bytes available to  split
87       among  the  key,  key_prefix, and value; for cas ASCII operations there
88       are at least 1318 bytes available to split among  the  key,  key_prefix
89       and  value.  If  the total size of the command, including overhead, ex‐
90       ceeds 1400 bytes, a MEMCACHED_WRITE_FAILURE will be returned.
91

RETURN VALUE

93       All methods return a value of type memcached_return_t.
94
95       On success the value will  be  MEMCACHED_SUCCESS.   Use  memcached_str‐
96       error() to translate this value to a printable string.
97
98       For  memcached_replace()  and memcached_add(), MEMCACHED_NOTSTORED is a
99       legitimate error in the case of a collision.
100

SEE ALSO

102       memcached(1) libmemcached(3) memcached_strerror(3) memcached_prepend(3)
103       memcached_append(3) memcached_cas(3)
104
105
106
107
1081.1                              Sep 20, 2021          MEMCACHED_ADD_BY_KEY(3)
Impressum