Merge in trunk
[m6w6/libmemcached] / docs / man / memcached_get_by_key.3
1 .TH "MEMCACHED_GET_BY_KEY" "3" "October 18, 2011" "1.01" "libmemcached"
2 .SH NAME
3 memcached_get_by_key \- 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\fI\ *ptr\fP, memcached_result_st\fI\ *result\fP, memcached_return_t\fI\ *error\fP)
39 .UNINDENT
40 .INDENT 0.0
41 .TP
42 .B char * memcached_get(memcached_st\fI\ *ptr\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, size_t\fI\ *value_length\fP, uint32_t\fI\ *flags\fP, memcached_return_t\fI\ *error\fP)
43 .UNINDENT
44 .INDENT 0.0
45 .TP
46 .B memcached_return_t memcached_mget(memcached_st\fI\ *ptr\fP, const char * const\fI\ *keys\fP, const size_t\fI\ *key_length\fP, size_t\fI\ number_of_keys\fP)
47 .UNINDENT
48 .INDENT 0.0
49 .TP
50 .B char * memcached_get_by_key(memcached_st\fI\ *ptr\fP, const char\fI\ *group_key\fP, size_t\fI\ group_key_length\fP, const char\fI\ *key\fP, size_t\fI\ key_length\fP, size_t\fI\ *value_length\fP, uint32_t\fI\ *flags\fP, memcached_return_t\fI\ *error\fP)
51 .UNINDENT
52 .INDENT 0.0
53 .TP
54 .B memcached_return_t memcached_mget_by_key(memcached_st\fI\ *ptr\fP, const char\fI\ *group_key\fP, size_t\fI\ group_key_length\fP, const char * const\fI\ *keys\fP, const size_t\fI\ *key_length\fP, size_t\fI\ number_of_keys\fP)
55 .UNINDENT
56 .INDENT 0.0
57 .TP
58 .B memcached_return_t memcached_fetch_execute(memcached_st\fI\ *ptr\fP, memcached_execute_fn\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
59 .UNINDENT
60 .INDENT 0.0
61 .TP
62 .B memcached_return_t memcached_mget_execute(memcached_st\fI\ *ptr\fP, const char * const\fI\ *keys\fP, const size_t\fI\ *key_length\fP, size_t\fI\ number_of_keys\fP, memcached_execute_fn\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
63 .UNINDENT
64 .INDENT 0.0
65 .TP
66 .B memcached_return_t memcached_mget_execute_by_key(memcached_st\fI\ *ptr\fP, const char\fI\ *group_key\fP, size_t\fI\ group_key_length\fP, const char * const\fI\ *keys\fP, const size_t\fI\ *key_length\fP, size_t\fI\ number_of_keys\fP, memcached_execute_fn\fI\ *callback\fP, void\fI\ *context\fP, uint32_t\fI\ number_of_callbacks\fP)
67 .UNINDENT
68 .sp
69 Compile and link with \-lmemcached
70 .SH DESCRIPTION
71 .sp
72 \fI\%memcached_get()\fP is used to fetch an individual value from the server.
73 You must pass in a key and its length to fetch the object. You must supply
74 three pointer variables which will give you the state of the returned
75 object. A \fBuint32_t\fP pointer to contain whatever flags you stored with the value, a \fBsize_t\fP pointer which will be filled with size of of
76 the object, and a \fBmemcached_return_t\fP pointer to hold any error. The
77 object will be returned upon success and NULL will be returned on failure. Any
78 object returned by \fI\%memcached_get()\fP must be released by the caller
79 application.
80 .sp
81 \fI\%memcached_mget()\fP is used to select multiple keys at once. For
82 multiple key operations it is always faster to use this function. This function always works asynchronously.
83 .sp
84 To retrieve data after a successful execution of \fI\%memcached_mget()\fP, you will need to
85 call \fI\%memcached_fetch_result()\fP. You should continue to call this function until
86 it returns a NULL (i.e. no more values). If you need to quit in the middle of a
87 \fI\%memcached_mget()\fP call, you can execute a \fBmemcached_quit()\fP, those this is not required.
88 .sp
89 \fI\%memcached_fetch_result()\fP is used to fetch an individual value from the server. \fI\%memcached_mget()\fP must always be called before using this method.
90 You must pass in a key and its length to fetch the object. You must supply
91 three pointer variables which will give you the state of the returned
92 object. A \fBuint32_t\fP pointer to contain whatever flags you stored with the value, a \fBsize_t\fP pointer which will be filled with size of of the
93 object, and a \fBmemcached_return_t\fP pointer to hold any error. The
94 object will be returned upon success and NULL will be returned on failure. \fBMEMCACHD_END\fP is returned by the *error value when all objects that have been found are returned. The final value upon \fBMEMCACHED_END\fP is null.
95 .sp
96 \fI\%memcached_fetch_result()\fP is used to return a \fBmemcached_result_st\fP structure from a memcached server. The result object is forward compatible
97 with changes to the server. For more information please refer to the
98 \fBmemcached_result_st\fP help. This function will dynamically allocate a
99 result structure for you if you do not pass one to the function.
100 .sp
101 \fI\%memcached_fetch_execute()\fP is a callback function for result sets.
102 Instead of returning the results to you for processing, it passes each of the
103 result sets to the list of functions you provide. It passes to the function
104 a \fBmemcached_st\fP that can be cloned for use in the called
105 function (it can not be used directly). It also passes a result set which does
106 not need to be freed. Finally it passes a "context". This is just a pointer to
107 a memory reference you supply the calling function. Currently only one value
108 is being passed to each function call. In the future there will be an option
109 to allow this to be an array.
110 .sp
111 \fI\%memcached_mget_execute()\fP and \fI\%memcached_mget_execute_by_key()\fP
112 is similar to \fI\%memcached_mget()\fP, but it may trigger the supplied
113 callbacks with result sets while sending out the queries. If you try to
114 perform a really large multiget with \fI\%memcached_mget()\fP you may
115 encounter a deadlock in the OS kernel (it will fail to write data to the
116 socket because the input buffer is full). \fI\%memcached_mget_execute()\fP
117 solves this problem by processing some of the results before continuing
118 sending out requests. Please note that this function is only available in
119 the binary protocol.
120 .sp
121 \fI\%memcached_get_by_key()\fP and \fI\%memcached_mget_by_key()\fP behave
122 in a similar nature as \fI\%memcached_get()\fP and \fI\%memcached_mget()\fP.
123 The difference is that they take a master key that is used for determining
124 which server an object was stored if key partitioning was used for storage.
125 .sp
126 All of the above functions are not tested when the
127 \fBMEMCACHED_BEHAVIOR_USE_UDP\fP has been set. Executing any of these
128 functions with this behavior on will result in \fBMEMCACHED_NOT_SUPPORTED\fP being returned, or for those functions which do not return a \fBmemcached_return_t\fP, the error function parameter will be set to \fBMEMCACHED_NOT_SUPPORTED\fP.
129 .SH RETURN
130 .sp
131 All objects retrieved via \fI\%memcached_get()\fP or \fI\%memcached_get_by_key()\fP must be freed with \fIfree(3)\fP.
132 .sp
133 \fI\%memcached_get()\fP will return NULL on
134 error. You must look at the value of error to determine what the actual error
135 was.
136 .sp
137 \fI\%memcached_fetch_execute()\fP return \fBMEMCACHED_SUCCESS\fP if
138 all keys were successful. \fBMEMCACHED_NOTFOUND\fP will be return if no
139 keys at all were found.
140 .sp
141 \fI\%memcached_fetch_result()\fP sets error
142 to \fBMEMCACHED_END\fP upon successful conclusion.
143 \fBMEMCACHED_NOTFOUND\fP will be return if no keys at all were found.
144 .SH HOME
145 .sp
146 To find out more information please check:
147 \fI\%http://libmemcached.org/\fP
148 .SH SEE ALSO
149 .sp
150 \fImemcached(1)\fP \fIlibmemcached(3)\fP \fImemcached_strerror(3)\fP
151 .SH AUTHOR
152 Brian Aker
153 .SH COPYRIGHT
154 2011, Brian Aker DataDifferential, http://datadifferential.com/
155 .\" Generated by docutils manpage writer.
156 .\"
157 .