-
Notifications
You must be signed in to change notification settings - Fork 860
Expand file tree
/
Copy pathset.xml
More file actions
179 lines (163 loc) · 5.08 KB
/
set.xml
File metadata and controls
179 lines (163 loc) · 5.08 KB
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
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="memcache.set">
<refnamediv>
<refname>Memcache::set</refname>
<refname>memcache_set</refname>
<refpurpose>Store data at the server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>Memcache::set</methodname>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flag</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>expire</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<type>bool</type><methodname>memcache_set</methodname>
<methodparam><type>Memcache</type><parameter>memcache</parameter></methodparam>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flag</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>expire</parameter></methodparam>
</methodsynopsis>
<para>
<function>Memcache::set</function> stores an item
<parameter>var</parameter> with <parameter>key</parameter> on the
memcached server. Parameter <parameter>expire</parameter> is expiration
time in seconds. If it's 0, the item never expires (but memcached server
doesn't guarantee this item to be stored all the time, it could be deleted
from the cache to make place for other items).
You can use <constant>MEMCACHE_COMPRESSED</constant> constant as
<parameter>flag</parameter> value if you want to use on-the-fly
compression (uses zlib).
<note>
<simpara>
Remember that resource variables (i.e. file and connection descriptors)
cannot be stored in the cache, because they cannot be adequately
represented in serialized state.
</simpara>
</note>
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>key</parameter></term>
<listitem>
<simpara>
The key that will be associated with the item.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>var</parameter></term>
<listitem>
<simpara>
The variable to store. Strings and integers are stored as is, other
types are stored serialized.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flag</parameter></term>
<listitem>
<simpara>
Use <constant>MEMCACHE_COMPRESSED</constant> to store the item
compressed (uses zlib).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>expire</parameter></term>
<listitem>
<simpara>
Expiration time of the item. If it's equal to zero, the item will never
expire. You can also use Unix timestamp or a number of seconds starting
from current time, but in the latter case the number of seconds may not
exceed 2592000 (30 days).
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
&return.success;
</simpara>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>Memcache::set</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
/* procedural API */
/* connect to memcached server */
$memcache_obj = memcache_connect('memcache_host', 11211);
/*
set value of item with key 'var_key'
using 0 as flag value, compression is not used
expire time is 30 seconds
*/
memcache_set($memcache_obj, 'var_key', 'some variable', 0, 30);
echo memcache_get($memcache_obj, 'var_key');
?>
]]>
</programlisting>
</example>
<example>
<title><function>Memcache::set</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
/* OO API */
$memcache_obj = new Memcache;
/* connect to memcached server */
$memcache_obj->connect('memcache_host', 11211);
/*
set value of item with key 'var_key', using on-the-fly compression
expire time is 50 seconds
*/
$memcache_obj->set('var_key', 'some really big variable', MEMCACHE_COMPRESSED, 50);
echo $memcache_obj->get('var_key');
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>Memcache::add</function></member>
<member><function>Memcache::replace</function></member>
</simplelist>
</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
-->