Merge Trunk
[awesomized/libmemcached] / docs / man / memcached_fetch.3
1 .TH "MEMCACHED_FETCH" "3" "June 17, 2011" "0.49" "libmemcached"
2 .SH NAME
3 memcached_fetch \- Retrieving data from the server
4 .
5 .nr rst2man-indent-level 0
6 .
7 .de1 rstReportMargin
8 \\$1 \\n[an-margin]
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
11 -
12 \\n[rst2man-indent0]
13 \\n[rst2man-indent1]
14 \\n[rst2man-indent2]
15 ..
16 .de1 INDENT
17 .\" .rstReportMargin pre:
18 . RS \\$1
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
22 ..
23 .de UNINDENT
24 . RE
25 .\" indent \\n[an-margin]
26 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27 .nr rst2man-indent-level -1
28 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
30 ..
31 .\" Man page generated from reStructeredText.
32 .
33 .SH SYNOPSIS
34 .sp
35 #include <libmemcached/memcached.h>
36 .INDENT 0.0
37 .TP
38 .B memcached_result_st * memcached_fetch_result (memcached_st *ptr, memcached_result_st *result, memcached_return_t *error);
39 .UNINDENT
40 .INDENT 0.0
41 .TP
42 .B char * memcached_get (memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error);
43 .UNINDENT
44 .INDENT 0.0
45 .TP
46 .B memcached_return_t memcached_mget (memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys);
47 .UNINDENT
48 .INDENT 0.0
49 .TP
50 .B char * memcached_get_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error);
51 .UNINDENT
52 .INDENT 0.0
53 .TP
54 .B memcached_return_t memcached_mget_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys);
55 .UNINDENT
56 .INDENT 0.0
57 .TP
58 .B char * memcached_fetch (memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error);
59 .UNINDENT
60 .INDENT 0.0
61 .TP
62 .B memcached_return_t memcached_fetch_execute (memcached_st *ptr, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks);
63 .UNINDENT
64 .INDENT 0.0
65 .TP
66 .B memcached_return_t memcached_mget_execute (memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks);
67 .UNINDENT
68 .INDENT 0.0
69 .TP
70 .B memcached_return_t memcached_mget_execute_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks);
71 .UNINDENT
72 .sp
73 Compile and link with \-lmemcached
74 .SH DESCRIPTION
75 .sp
76 memcached_get() is used to fetch an individual value from the server. You
77 must pass in a key and its length to fetch the object. You must supply
78 three pointer variables which will give you the state of the returned
79 object. A uint32_t pointer to contain whatever flags you stored with the value,
80 a size_t pointer which will be filled with size of of the object, and a
81 memcached_return_t pointer to hold any error. The object will be returned
82 upon success and NULL will be returned on failure. Any object returned by
83 memcached_get() must be released by the caller application.
84 .sp
85 memcached_mget() is used to select multiple keys at once. For multiple key
86 operations it is always faster to use this function. This function always
87 works asynchronously. memcached_fetch() is then used to retrieve any keys
88 found. No error is given on keys that are not found. You must call either
89 memcached_fetch() or memcached_fetch_result() after a successful call to
90 memcached_mget(). You should continue to call these functions until they
91 return NULL (aka no more values). If you need to quit in the middle of a
92 memcached_get() call, execute a memcached_quit(). After you do this, you can
93 issue new queries against the server.
94 .sp
95 memcached_fetch() is used to fetch an individual value from the server.
96 memcached_mget() must always be called before using this method. You
97 must pass in a key and its length to fetch the object. You must supply
98 three pointer variables which will give you the state of the returned
99 object. A uint32_t pointer to contain whatever flags you stored with the value,
100 a size_t pointer which will be filled with size of of the object, and a
101 memcached_return_t pointer to hold any error. The object will be returned
102 upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is
103 returned by the *error value when all objects that have been found are
104 returned. The final value upon \fBMEMCACHED_END\fP is null. Values
105 returned by memcached_fetch() must be freed by the caller. memcached_fetch()
106 will be DEPRECATED in the near future, memcached_fetch_result() should be
107 used instead.
108 .sp
109 memcached_fetch_result() is used to return a memcached_result_st(3) structure
110 from a memcached server. The result object is forward compatible with changes
111 to the server. For more information please refer to the memcached_result_st(3)
112 help. This function will dynamically allocate a result structure for you
113 if you do not pass one to the function.
114 .sp
115 memcached_fetch_execute() is a callback function for result sets. Instead
116 of returning the results to you for processing, it passes each of the
117 result sets to the list of functions you provide. It passes to the function
118 a memcached_st that can be cloned for use in the called function (it can not
119 be used directly). It also passes a result set which does not need to be freed.
120 Finally it passes a "context". This is just a pointer to a memory reference
121 you supply the calling function. Currently only one value is being passed
122 to each function call. In the future there will be an option to allow this
123 to be an array.
124 .sp
125 memcached_mget_execute() and memcached_mget_execute_by_key() is
126 similar to memcached_mget(), but it may trigger the supplied callbacks
127 with result sets while sending out the queries. If you try to perform
128 a really large multiget with memcached_mget() you may encounter a
129 deadlock in the OS kernel (it will fail to write data to the socket because
130 the input buffer is full). memcached_mget_execute() solves this
131 problem by processing some of the results before continuing sending
132 out requests. Please note that this function is only available in the
133 binary protocol.
134 .sp
135 memcached_get_by_key() and memcached_mget_by_key() behave in a similar nature
136 as memcached_get() and memcached_mget(). The difference is that they take
137 a master key that is used for determining which server an object was stored
138 if key partitioning was used for storage.
139 .sp
140 All of the above functions are not tested when the \fBMEMCACHED_BEHAVIOR_USE_UDP\fPhas been set. Executing any of these functions with this behavior on will result in
141 \fBMEMCACHED_NOT_SUPPORTED\fP being returned, or for those functions which do not return
142 a \fBmemcached_return_t\fP, the error function parameter will be set to
143 \fBMEMCACHED_NOT_SUPPORTED\fP.
144 .SH RETURN
145 .sp
146 All objects returned must be freed by the calling application.
147 memcached_get() and memcached_fetch() will return NULL on error. You must
148 look at the value of error to determine what the actual error was.
149 .sp
150 \fBmemcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
151 all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
152 keys at all were found.
153 .sp
154 \fBmemcached_fetch()\fP and \fBmemcached_fetch_result()\fP set error
155 to \fBMEMCACHED_END\fP upon successful conclusion.
156 \fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
157 .sp
158 MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used
159 and the key was set larger then MEMCACHED_MAX_KEY, which was the largest
160 key allowed for the original memcached ascii server.
161 .SH HOME
162 .sp
163 To find out more information please check:
164 \fI\%http://libmemcached.org/\fP
165 .SH SEE ALSO
166 .sp
167 \fImemcached(1)\fP \fIlibmemcached(3)\fP \fImemcached_strerror(3)\fP
168 .SH AUTHOR
169 Brian Aker
170 .SH COPYRIGHT
171 2011, Brian Aker DataDifferential, http://datadifferential.com/
172 .\" Generated by docutils manpage writer.
173 .\"
174 .