1..::docs::memcached_get(3) libmemcached ..::docs::memcached_get(3)
2
3
4
6 memcached_get, memcached_mget, memcached_fetch - Get a value
7
9 C Client Library for memcached (libmemcached, -lmemcached)
10
12 #include <memcached.h>
13
14 memcached_result_st *
15 memcached_fetch_result(memcached_st *ptr,
16 memcached_result_st *result,
17 memcached_return *error);
18
19 char *memcached_get (memcached_st *ptr,
20 const char *key, size_t key_length,
21 size_t *value_length,
22 uint32_t *flags,
23 memcached_return *error);
24
25 memcached_return
26 memcached_mget (memcached_st *ptr,
27 char **keys, size_t *key_length,
28 unsigned int number_of_keys);
29 char *
30 memcached_get_by_key(memcached_st *ptr,
31 const char *master_key, size_t master_key_length,
32 const char *key, size_t key_length,
33 size_t *value_length,
34 uint32_t *flags,
35 memcached_return *error);
36
37 memcached_return
38 memcached_mget_by_key(memcached_st *ptr,
39 const char *master_key, size_t master_key_length,
40 char **keys, size_t *key_length,
41 unsigned int number_of_keys);
42
43 char *memcached_fetch (memcached_st *ptr,
44 char *key, size_t *key_length,
45 size_t *value_length,
46 uint32_t *flags,
47 memcached_return *error);
48 memcached_return
49 memcached_fetch_execute(memcached_st *ptr,
50 memcached_return (*callback[])(memcached_st *ptr, memcached_result_st *result, void *context),
51 void *context,
52 unsigned int number_of_callbacks);
53
55 memcached_get() is used to fetch an individual value from the server.
56 You must pass in a key and its length to fetch the object. You must
57 supply three pointer variables which will give you the state of the
58 returned object. A uint32_t pointer to contain whatever flags you
59 stored with the value, a size_t pointer which will be filled with size
60 of of the object, and a memcached_return pointer to hold any error. The
61 object will be returned upon success and NULL will be returned on
62 failure. Any object returned by memcached_get() must be released by the
63 caller application.
64
65 memcached_mget() is used to select multiple keys at once. For multiple
66 key operations it is always faster to use this function. This function
67 always works asynchronously. memcached_fetch() is then used to retrieve
68 any keys found. No error is given on keys that are not found. You must
69 call either memcached_fetch() or memcached_fetch_result() after a
70 successful call to memcached_mget(). You should continue to call these
71 functions until they return NULL (aka no more values). If you need to
72 quit in the middle of a memcached_get() call, execute a
73 memcached_quit(). After you do this, you can issue new queries against
74 the server.
75
76 memcached_fetch() is used to fetch an individual value from the server.
77 memcached_mget() must always be called before using this method. You
78 must pass in a key and its length to fetch the object. You must supply
79 three pointer variables which will give you the state of the returned
80 object. A uint32_t pointer to contain whatever flags you stored with
81 the value, a size_t pointer which will be filled with size of of the
82 object, and a memcached_return pointer to hold any error. The object
83 will be returned upon success and NULL will be returned on failure.
84 MEMCACHD_END is returned by the *error value when all objects that have
85 been found are returned. The final value upon MEMCACHED_END is null.
86 Values returned by memcached_fetch() musted be free'ed by the caller.
87
88 memcached_fetch_result() is used to return a memcached_result_st(3)
89 structure from a memcached server. The result object is forward
90 compatible with changes to the server. For more information please
91 refer to the memcached_result_st(3) help. This function will
92 dynamically allocate a result structure for you if you do not pass one
93 to the function.
94
95 memcached_fetch_execute() is a callback function for result sets.
96 Instead of returning the results to you for processing, it passes each
97 of the result sets to the list of functions you provide. It passes to
98 the function a memcached_st that can be cloned for use in the called
99 function (it can not be used directly). It also passes a result set
100 which does not need to be freed. Finally it passes a "context". This
101 is just a pointer to a memory reference you supply the calling
102 function. Currently only one value is being passed to each function
103 call. In the future there will be an option to allow this to be an
104 array.
105
106 memcached_get_by_key() and memcached_mget_by_key() behave in a similar
107 nature as memcached_get() and memcached_mget(). The difference is that
108 they take a master key that is used for determining which server an
109 object was stored if key partitioning was used for storage.
110
111 All of the above functions are not supported when the
112 "MEMCACHED_BEHAVIOR_USE_UDP" has been set. Executing any of these
113 functions with this behavior on will result in
114 "MEMCACHED_NOT_SUPPORTED" being returned or, for those functions which
115 do not return a "memcached_return", the error function parameter will
116 be set to "MEMCACHED_NOT_SUPPORTED".
117
119 All objects returned must be freed by the calling application.
120 memcached_get() and memcached_fetch() will return NULL on error. You
121 must look at the value of error to determine what the actual error was.
122
124 To find out more information please check:
125 <http://tangent.org/552/libmemcached.html>
126
128 Brian Aker, <brian@tangent.org>
129
131 memcached(1) libmemcached(3) memcached_strerror(3)
132
133
134
135 2009-05-20 ..::docs::memcached_get(3)