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

NAME

6       memcached_set - 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
74       MEMCACHED_BEHAVIOR_USE_UDP behavior enabled. However, when using  these
75       operations  with  this behavior on, there are limits to the size of the
76       payload being sent to the server.  The reason for these limits is  that
77       the  Memcached  Server  does  not allow multi-datagram requests and the
78       current server implementation sets a datagram size to 1400  bytes.  Due
79       to  protocol  overhead,  the  actual limit of the user supplied data is
80       less than 1400 bytes and depends on the protocol in use, as well as the
81       operation  being  executed.  When  running  with  the  binary protocol,
82       MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, the size of  the  key,value,  flags
83       and  expiry  combined  may not exceed 1368 bytes. When running with the
84       ASCII protocol, the exact limit fluctuates depending on which  function
85       is  being  executed and whether the function is a cas operation or not.
86       For non-cas ASCII set operations, there are at least 1335 bytes  avail‐
87       able to split among the key, key_prefix, and value; for cas ASCII oper‐
88       ations there are at least 1318 bytes available to split among the  key,
89       key_prefix and value. If the total size of the command, including over‐
90       head, exceeds 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
96       memcached_strerror() 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                              Nov 09, 2022                 MEMCACHED_SET(3)
Impressum