1MEMCACHED_FETCH_EXECUTE(3) libmemcached-awesome MEMCACHED_FETCH_EXECUTE(3)
2
3
4
6 memcached_fetch_execute - Retrieving data from the server
7
9 #include <libmemcached/memcached.h>
10 Compile and link with -lmemcached
11
12 memcached_result_st *memcached_fetch_result(memcached_st *ptr,
13 memcached_result_st *result, memcached_return_t *error)
14
15 char *memcached_get(memcached_st *ptr, const char *key, size_t
16 key_length, size_t *value_length, uint32_t *flags, memcached_return_t
17 *error)
18
19 memcached_return_t memcached_mget(memcached_st *ptr, const char *const
20 *keys, const size_t *key_length, size_t number_of_keys)
21
22 char *memcached_get_by_key(memcached_st *ptr, const char *group_key,
23 size_t group_key_length, const char *key, size_t key_length, size_t
24 *value_length, uint32_t *flags, memcached_return_t *error)
25
26 memcached_return_t memcached_mget_by_key(memcached_st *ptr, const char
27 *group_key, size_t group_key_length, const char *const *keys, const
28 size_t *key_length, size_t number_of_keys)
29
30 memcached_return_t memcached_fetch_execute(memcached_st *ptr,
31 memcached_execute_fn *callback, void *context, uint32_t number_of_call‐
32 backs)
33
34 memcached_return_t memcached_mget_execute(memcached_st *ptr, const char
35 *const *keys, const size_t *key_length, size_t number_of_keys,
36 memcached_execute_fn *callback, void *context, uint32_t number_of_call‐
37 backs)
38
39 memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr,
40 const char *group_key, size_t group_key_length, const char *const
41 *keys, const size_t *key_length, size_t number_of_keys,
42 memcached_execute_fn *callback, void *context, uint32_t number_of_call‐
43 backs)
44
45 typedef memcached_return_t (*memcached_execute_fn)(const memcached_st
46 *ptr, memcached_result_st *result, void *context)
47
49 memcached_get() is used to fetch an individual value from the server.
50 You must pass in a key and its length to fetch the object. You must
51 supply three pointer variables which will give you the state of the re‐
52 turned object. A uint32_t pointer to contain whatever flags you stored
53 with the value, a size_t pointer which will be filled with size of of
54 the object, and a memcached_return_t pointer to hold any error. The ob‐
55 ject will be returned upon success and NULL will be returned on fail‐
56 ure. Any object returned by memcached_get() must be released by the
57 caller application.
58
59 memcached_mget() is used to select multiple keys at once. For multiple
60 key operations it is always faster to use this function. This function
61 always works asynchronously.
62
63 To retrieve data after a successful execution of memcached_mget(), you
64 will need to call memcached_fetch_result(). You should continue to
65 call this function until it returns a NULL (i.e. no more values). If
66 you need to quit in the middle of a memcached_mget() call, you can exe‐
67 cute a memcached_quit(), those this is not required.
68
69 memcached_fetch_result() is used to fetch an individual value from the
70 server. memcached_mget() must always be called before using this
71 method. You must pass in a key and its length to fetch the object. You
72 must supply three pointer variables which will give you the state of
73 the returned object. A uint32_t pointer to contain whatever flags you
74 stored with the value, a size_t pointer which will be filled with size
75 of of the object, and a memcached_return_t pointer to hold any error.
76 The object will be returned upon success and NULL will be returned on
77 failure. MEMCACHED_END is returned by the *error value when all objects
78 that have been found have been returned. The final value upon
79 MEMCACHED_END is null.
80
81 memcached_fetch_result() is used to return a memcached_result_st struc‐
82 ture from a memcached server. The result object is forward compatible
83 with changes to the server. For more information please refer to the
84 memcached_result_st help. This function will dynamically allocate a re‐
85 sult structure for you if you do not pass one to the function.
86
87 memcached_fetch_execute() is a callback function for result sets. In‐
88 stead of returning the results to you for processing, it passes each of
89 the result sets to the list of functions you provide. It passes to the
90 function a memcached_st that can be cloned for use in the called func‐
91 tion (it can not be used directly). It also passes a result set which
92 does not need to be freed. Finally it passes a "context". This is just
93 a pointer to a memory reference you supply the calling function. Cur‐
94 rently only one value is being passed to each function call. In the fu‐
95 ture there will be an option to allow this to be an array.
96
97 memcached_mget_execute() and memcached_mget_execute_by_key() is similar
98 to memcached_mget(), but it may trigger the supplied callbacks with re‐
99 sult sets while sending out the queries. If you try to perform a really
100 large multiget with memcached_mget() you may encounter a deadlock in
101 the OS kernel (it will fail to write data to the socket because the in‐
102 put buffer is full). memcached_mget_execute() solves this problem by
103 processing some of the results before continuing sending out requests.
104 Please note that this function is only available in the binary proto‐
105 col.
106
107 memcached_get_by_key() and memcached_mget_by_key() behave in a similar
108 nature as memcached_get() and memcached_mget(). The difference is that
109 they take a master key that is used for determining which server an ob‐
110 ject was stored if key partitioning was used for storage.
111
112 All of the above functions are not tested when the
113 MEMCACHED_BEHAVIOR_USE_UDP has been set. Executing any of these func‐
114 tions with this behavior on will result in MEMCACHED_NOT_SUPPORTED be‐
115 ing returned, or for those functions which do not return a
116 memcached_return_t, the error function parameter will be set to
117 MEMCACHED_NOT_SUPPORTED.
118
120 All objects retrieved via memcached_get() or memcached_get_by_key()
121 must be freed with free(3).
122
123 memcached_get() will return NULL on error. You must look at the value
124 of error to determine what the actual error was.
125
126 memcached_fetch_execute() return MEMCACHED_SUCCESS if all keys were
127 successful. MEMCACHED_NOTFOUND will be returned if no keys at all were
128 found.
129
130 memcached_fetch_result() sets error to MEMCACHED_END upon successful
131 conclusion. MEMCACHED_NOTFOUND will be returned if no keys at all were
132 found.
133
135 memcached(1) libmemcached(3) memcached_strerror(3)
136
137
138
139
1401.1 Nov 09, 2022 MEMCACHED_FETCH_EXECUTE(3)