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

NAME

6       memcached_set - Storing and Replacing Data
7

SYNOPSIS

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

DESCRIPTION

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

RETURN

101       All  methods return a value of type memcached_return_t.  On success the
102       value will be MEMCACHED_SUCCESS.  Use memcached_strerror() to translate
103       this value to a printable string.
104
105       For  memcached_replace()  and memcached_add(), MEMCACHED_NOTSTORED is a
106       legitmate error in the case of a collision.
107

HOME

109       To find out more information please check: http://libmemcached.org/
110

SEE ALSO

112       memcached(1) libmemached(3) memcached_strerror(3)  memcached_prepend(3)
113       memcached_cas(3) memcached_append(3)
114

AUTHOR

116       Brian Aker
117
119       2011-2013, Brian Aker DataDifferential, http://datadifferential.com/
120
121
122
123
1241.0.18                         February 09, 2014              MEMCACHED_SET(3)
Impressum