/
getmulti.xml
202 lines (189 loc) · 4.88 KB
/
getmulti.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="memcached.getmulti" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Memcached::getMulti</refname>
<refpurpose>Retrieve multiple items</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>Memcached::getMulti</methodname>
<methodparam><type>array</type><parameter>keys</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter role="reference">cas_tokens</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
<para>
<function>Memcached::getMulti</function> is similar to
<methodname>Memcached::get</methodname>, but instead of a single key
item, it retrieves multiple items the keys of which are specified in the
<parameter>keys</parameter> array. If <parameter>cas_tokens</parameter>
variable is provided, it is filled with the CAS token values for the found
items.
<note>
<para>
Unlike <methodname>Memcached::get</methodname> it is not possible to
specify a read-through cache callback for
<function>Memcached::getMulti</function>, because the memcache protocol
does not provide information on which keys were not found in the multi-key
request.
</para>
</note>
</para>
<para>
The <parameter>flags</parameter> parameter can be used to specify
additional options for <function>Memcached::getMulti</function>. Currently,
the only available option is
<constant>Memcached::GET_PRESERVE_ORDER</constant> that ensures that the
keys are returned in the same order as they were requested in.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>keys</parameter></term>
<listitem>
<para>
Array of keys to retrieve.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>cas_tokens</parameter></term>
<listitem>
<para>
The variable to store the CAS tokens for the found items.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
The flags for the get operation.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the array of found items&return.falseforfailure;.
&memcached.result.getresultcode;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>Memcached::getMulti</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$items = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
);
$m->setMulti($items);
$result = $m->getMulti(array('key1', 'key3', 'badkey'), $cas);
var_dump($result, $cas);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
array(2) {
["key1"]=>
string(6) "value1"
["key3"]=>
string(6) "value3"
}
array(2) {
["key1"]=>
float(2360)
["key3"]=>
float(2362)
}
]]>
</screen>
</example>
</para>
<para>
<example>
<title><constant>Memcached::GET_PRESERVE_ORDER</constant> example</title>
<programlisting role="php">
<![CDATA[
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$data = array(
'foo' => 'foo-data',
'bar' => 'bar-data',
'baz' => 'baz-data',
'lol' => 'lol-data',
'kek' => 'kek-data',
);
$m->setMulti($data, 3600);
$null = null;
$keys = array_keys($data);
$keys[] = 'zoo';
$got = $m->getMulti($keys, $null, Memcached::GET_PRESERVE_ORDER);
foreach ($got as $k => $v) {
echo "$k $v\n";
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
foo foo-data
bar bar-data
baz baz-data
lol lol-data
kek kek-data
zoo
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>Memcached::getMultiByKey</methodname></member>
<member><methodname>Memcached::get</methodname></member>
<member><methodname>Memcached::getDelayed</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->