📄 function.memcache-connect.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Open memcached server connection</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.memcache-close.html">Memcache::close</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.memcache-debug.html">memcache_debug</a></div> <div class="up"><a href="ref.memcache.html">Memcache Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.memcache-connect" class="refentry"> <div class="refnamediv"> <h1 class="refname">Memcache::connect</h1> <p class="verinfo">(PECL memcache:0.2-2.1.2)</p><p class="refpurpose"><span class="refname">Memcache::connect</span> — <span class="dc-title">Open memcached server connection</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>Memcache::connect</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$host</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$port</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$timeout</tt></span> ]] )</div> <p class="para rdfs-comment"> <b>Memcache::connect()</b> establishes a connection to the memcached server. The connection, which was opened using <b>Memcache::connect()</b> will be automatically closed at the end of script execution. Also you can close it with <a href="function.memcache-close.html" class="function">Memcache::close()</a>. Also you can use <b>memcache_connect()</b> function. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">host</tt></i></span> <dd> <p class="para"> Point to the host where memcached is listening for connections. This parameter may also specify other transports like <i>unix:///path/to/memcached.sock</i> to use UNIX domain sockets, in this case <i><tt class="parameter">port</tt></i> must also be set to <i>0</i>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">port</tt></i></span> <dd> <p class="para"> Point to the port where memcached is listening for connections. Set this parameter to <i>0</i> when using UNIX domain sockets. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">timeout</tt></i></span> <dd> <p class="para"> Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>Memcache::connect()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">/* procedural API */<br /><br /></span><span style="color: #0000BB">$memcache_obj </span><span style="color: #007700">= </span><span style="color: #0000BB">memcache_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* OO API */<br /><br /></span><span style="color: #0000BB">$memcache </span><span style="color: #007700">= new </span><span style="color: #0000BB">Memcache</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$memcache</span><span style="color: #007700">-></span><span style="color: #0000BB">connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.memcache-pconnect.html" class="function" rel="rdfs-seeAlso">Memcache::pconnect()</a></li> <li class="member"><a href="function.memcache-close.html" class="function" rel="rdfs-seeAlso">Memcache::close()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.memcache-close.html">Memcache::close</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.memcache-debug.html">memcache_debug</a></div> <div class="up"><a href="ref.memcache.html">Memcache Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -