{"id":534,"date":"2008-09-28T00:00:00","date_gmt":"2008-09-27T16:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=534"},"modified":"2011-07-15T09:14:52","modified_gmt":"2011-07-15T01:14:52","slug":"memcache%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8d%8f%e8%ae%ae%e5%88%86%e6%9e%90%e8%af%a6%e8%a7%a3php","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=534","title":{"rendered":"Memcache\u7684\u4f7f\u7528\u548c\u534f\u8bae\u5206\u6790\u8be6\u89e3(php)"},"content":{"rendered":"<p><DIV><STRONG><FONT color=#993300 size=5>Memcache\u7684\u4f7f\u7528\u548c\u534f\u8bae\u5206\u6790\u8be6\u89e3<\/FONT><\/STRONG><br \/>\n<P><BR><EM>\u4f5c\u8005\uff1aheiyeluren<BR>\u535a\u5ba2\uff1a<\/EM><A href=\"http:\/\/blog.csdn.net\/heiyeshuwu\"><EM>http:\/\/blog.csdn.net\/heiyeshuwu<\/EM><\/A><BR><EM>\u65f6\u95f4\uff1a2006-11-12<BR>\u5173\u952e\u5b57\uff1aPHP Memcache Linux \u7f13\u5b58<\/EM><\/P><br \/>\n<P><BR>Memcache\u662fdanga.com\u7684\u4e00\u4e2a\u9879\u76ee\uff0c\u6700\u65e9\u662f\u4e3a LiveJournal \u670d\u52a1\u7684\uff0c\u76ee\u524d\u5168\u4e16\u754c\u4e0d\u5c11\u4eba\u4f7f\u7528\u8fd9\u4e2a\u7f13\u5b58\u9879\u76ee\u6765\u6784\u5efa\u81ea\u5df1\u5927\u8d1f\u8f7d\u7684\u7f51\u7ad9\uff0c\u6765\u5206\u62c5\u6570\u636e\u5e93\u7684\u538b\u529b\u3002\uff08\u5173\u4e8eMemcache\u7684\u66f4\u591a\u4fe1\u606f\u8bf7Google\uff09<BR>Memcache\u5b98\u65b9\u7f51\u7ad9\uff1a<A href=\"http:\/\/www.danga.com\/memcached\"><EM>http:\/\/www.danga.com\/memcached<\/EM><\/A><\/P><br \/>\n<P><BR><STRONG><FONT size=4>\u3010\u5b89\u88c5Memcache\u670d\u52a1\u5668\u7aef\u3011<\/FONT><\/STRONG><\/P><br \/>\n<P>\u6211\u76ee\u524d\u7684\u5e73\u53f0\uff0c\u670d\u52a1\u5668\u662fFedora Core 1\uff08\u5185\u6838\uff1a2.4.22\uff09\uff0c\u5ba2\u6237\u7aef\u662fWindows XP SP2\uff0c\u9700\u8981\u5b89\u88c5\u7684\u5c31\u662f\u670d\u52a1\u5668\u7684Memcached\u7684\u5b88\u62a4\u8fdb\u7a0b\u548c\u5ba2\u6237\u7aef\u7684PHP\u6269\u5c55php_memcache\u4e24\u4e2a\u4e1c\u897f\u3002\u73b0\u5728\u6211\u5206\u522b\u6765\u8bb2\u3002<\/P><br \/>\n<P>\u670d\u52a1\u5668\u7aef\u4e3b\u8981\u662f\u5b89\u88c5memcache\u670d\u52a1\u5668\u7aef\uff0c\u76ee\u524d\u7684\u6700\u65b0\u7248\u672c\u662f memcached-1.2.0 \u3002<BR>\u4e0b\u8f7d\uff1a<A href=\"http:\/\/www.danga.com\/memcached\/dist\/memcached-1.2.0.tar.gz\"><EM>http:\/\/www.danga.com\/memcached\/dist\/memcached-1.2.0.tar.gz<\/EM><\/A><BR>\u53e6\u5916\uff0cMemcache\u7528\u5230\u4e86libevent\u8fd9\u4e2a\u5e93\u7528\u4e8eSocket\u7684\u5904\u7406\uff0c\u6240\u4ee5\u8fd8\u9700\u8981\u5b89\u88c5libevent\uff0clibevent\u7684\u6700\u65b0\u7248\u672c\u662flibevent-1.2\u3002\uff08\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86libevent\uff0c\u53ef\u4ee5\u4e0d\u7528\u5b89\u88c5\uff09<BR>\u5b98\u7f51\uff1a<A href=\"http:\/\/www.monkey.org\/~provos\/libevent\/\"><EM>http:\/\/www.monkey.org\/~provos\/libevent\/<\/EM><\/A><BR>\u4e0b\u8f7d\uff1a<A href=\"http:\/\/www.monkey.org\/~provos\/libevent-1.2.tar.gz\"><EM>http:\/\/www.monkey.org\/~provos\/libevent-1.2.tar.gz<\/EM><\/A><\/P><br \/>\n<P>\u6211\u5206\u522b\u628a\u4e24\u4e2a\u4e1c\u4e1c\u4e0b\u8f7d\u56de\u6765\uff0c\u653e\u5230 \/tmp \u76ee\u5f55\u4e0b\uff1a<BR><FONT color=#0000ff># cd \/tmp<BR># wget <\/FONT><A href=\"http:\/\/www.danga.com\/memcached\/dist\/memcached-1.2.0.tar.gz\"><FONT color=#0000ff>http:\/\/www.danga.com\/memcached\/dist\/memcached-1.2.0.tar.gz<\/FONT><\/A><BR><FONT color=#0000ff># wget <\/FONT><A href=\"http:\/\/www.monkey.org\/~provos\/libevent-1.2.tar.gz\"><FONT color=#0000ff>http:\/\/www.monkey.org\/~provos\/libevent-1.2.tar.gz<\/FONT><\/A><\/P><br \/>\n<P>\u5148\u5b89\u88c5libevent\uff1a<BR><FONT color=#0000ff># tar zxvf libevent-1.2.tar.gz<BR># cd libevent-1.2<BR># .\/configure &#8211;prefix=\/usr<BR># make<BR># make install<\/FONT><\/P><br \/>\n<P>\u7136\u540e\u770b\u770b\u6211\u4eec\u7684libevent\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<BR><FONT color=#0000ff># ls -al \/usr\/lib | grep libevent<\/FONT><BR><FONT color=#993300>lrwxrwxrwx&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;21 11?? 12 17:38 libevent-1.2.so.1 -&gt; libevent-1.2.so.1.0.3<BR>-rwxr-xr-x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 263546 11?? 12 17:38 libevent-1.2.so.1.0.3<BR>-rw-r&#8211;r&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 454156 11?? 12 17:38 libevent.a<BR>-rwxr-xr-x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 811 11?? 12 17:38 libevent.la<BR>lrwxrwxrwx&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 21 11?? 12 17:38 libevent.so -&gt; libevent-1.2.so.1.0.3<\/FONT><\/P><br \/>\n<P>\u8fd8\u4e0d\u9519\uff0c\u90fd\u5b89\u88c5\u4e0a\u4e86\uff0c\u518d\u6765\u5b89\u88c5memcache\uff0c\u540c\u65f6\u9700\u8981\u5b89\u88c5\u4e2d\u6307\u5b9alibevent\u7684\u5b89\u88c5\u4f4d\u7f6e\uff1a<\/P><br \/>\n<P><FONT color=#0000ff># cd \/tmp<BR># tar zxvf memcached-1.2.0.tar.gz<BR># cd memcached-1.2.0<BR># .\/configure &#8211;with-libevent=\/usr<BR># make<BR># make install<\/FONT><\/P><br \/>\n<P>\u5982\u679c\u4e2d\u95f4\u51fa\u73b0\u62a5\u9519\uff0c\u8bf7\u4ed4\u7ec6\u68c0\u67e5\u9519\u8bef\u4fe1\u606f\uff0c\u6309\u7167\u9519\u8bef\u4fe1\u606f\u6765\u914d\u7f6e\u6216\u8005\u589e\u52a0\u76f8\u5e94\u7684\u5e93\u6216\u8005\u8def\u5f84\u3002<BR>\u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u628amemcached\u653e\u5230 \/usr\/local\/bin\/memcached \uff0c\u6211\u4eec\u770b\u4ee5\u4e0b\u662f\u5426\u5b89\u88c5\u4e86\uff1a<\/P><br \/>\n<P><FONT color=#0000ff># ls -al \/usr\/local\/bin\/mem*<\/FONT><BR><FONT color=#993300>-rwxr-xr-x&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 137986 11?? 12 17:39 \/usr\/local\/bin\/memcached<BR>-rwxr-xr-x&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 140179 11?? 12 17:39 \/usr\/local\/bin\/memcached-debug<\/FONT><\/P><br \/>\n<P>\u6069\uff0c\u5b89\u88c5\u5b8c\u6210\u4e86\uff0c\u73b0\u5728\u6211\u4eec\u770b\u4ee5\u4e0bmemcache\u7684\u5e2e\u52a9\uff1a<\/P><br \/>\n<P><FONT color=#0000ff># \/usr\/local\/bin\/memecached -h<\/FONT><BR><FONT color=#993300>memcached 1.2.0<BR>-p &lt;num&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;port number to listen on<BR>-s &lt;file&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unix socket path to listen on (disables network support)<BR>-l &lt;ip_addr&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interface to listen on, default is INDRR_ANY<BR>-d&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; run as a daemon<BR>-r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maximize core file limit<BR>-u &lt;username&gt; assume identity of &lt;username&gt; (only when run as root)<BR>-m &lt;num&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max memory to use for items in megabytes, default is 64 MB<BR>-M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return error on memory exhausted (rather than removing items)<BR>-c &lt;num&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max simultaneous connections, default is 1024<BR>-k&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lock down all paged memory<BR>-v&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; verbose (print errors\/warnings while in event loop)<BR>-vv&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;very verbose (also print client commands\/reponses)<BR>-h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print this help and exit<BR>-i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print memcached and libevent license<BR>-b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; run a managed instanced (mnemonic: buckets)<BR>-P &lt;file&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; save PID in &lt;file&gt;, only used with -d option<BR>-f &lt;factor&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chunk size growth factor, default 1.25<BR>-n &lt;bytes&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; minimum space allocated for key+value+flags, default 48<\/FONT><\/P><br \/>\n<P>\u53c2\u6570\u4e0d\u7b97\u591a\uff0c\u6211\u4eec\u6765\u542f\u52a8\u4e00\u4e2aMemcache\u7684\u670d\u52a1\u5668\u7aef\uff1a<BR><FONT color=#0000ff># \/usr\/local\/bin\/memcached -d -m 10&nbsp; -u root -l 192.168.0.200 -p 12000 -c 256 -P \/tmp\/memcached.pid<\/FONT><\/P><br \/>\n<P>-d\u9009\u9879\u662f\u542f\u52a8\u4e00\u4e2a\u5b88\u62a4\u8fdb\u7a0b\uff0c-m\u662f\u5206\u914d\u7ed9Memcache\u4f7f\u7528\u7684\u5185\u5b58\u6570\u91cf\uff0c\u5355\u4f4d\u662fMB\uff0c\u6211\u8fd9\u91cc\u662f10MB\uff0c-u\u662f\u8fd0\u884cMemcache\u7684\u7528\u6237\uff0c\u6211\u8fd9\u91cc\u662froot\uff0c-l\u662f\u76d1\u542c\u7684\u670d\u52a1\u5668IP\u5730\u5740\uff0c\u5982\u679c\u6709\u591a\u4e2a\u5730\u5740\u7684\u8bdd\uff0c\u6211\u8fd9\u91cc\u6307\u5b9a\u4e86\u670d\u52a1\u5668\u7684IP\u5730\u5740192.168.0.200\uff0c-p\u662f\u8bbe\u7f6eMemcache\u76d1\u542c\u7684\u7aef\u53e3\uff0c\u6211\u8fd9\u91cc\u8bbe\u7f6e\u4e8612000\uff0c\u6700\u597d\u662f1024\u4ee5\u4e0a\u7684\u7aef\u53e3\uff0c-c\u9009\u9879\u662f\u6700\u5927\u8fd0\u884c\u7684\u5e76\u53d1\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u662f1024\uff0c\u6211\u8fd9\u91cc\u8bbe\u7f6e\u4e86256\uff0c\u6309\u7167\u4f60\u670d\u52a1\u5668\u7684\u8d1f\u8f7d\u91cf\u6765\u8bbe\u5b9a\uff0c-P\u662f\u8bbe\u7f6e\u4fdd\u5b58Memcache\u7684pid\u6587\u4ef6\uff0c\u6211\u8fd9\u91cc\u662f\u4fdd\u5b58\u5728 \/tmp\/memcached.pid\uff0c\u5982\u679c\u8981\u7ed3\u675fMemcache\u8fdb\u7a0b\uff0c\u6267\u884c\uff1a<BR><FONT color=#0000ff># kill `cat \/tmp\/memcached.pid`<\/FONT><BR><BR>\u4e5f\u53ef\u4ee5\u542f\u52a8\u591a\u4e2a\u5b88\u62a4\u8fdb\u7a0b\uff0c\u4e0d\u8fc7\u7aef\u53e3\u4e0d\u80fd\u91cd\u590d\u3002<BR><\/P><br \/>\n<P><FONT size=4><STRONG>\u3010\u5b89\u88c5Memcache\u7684PHP\u6269\u5c55\u3011<\/STRONG><\/FONT><\/P><br \/>\n<P>Memcache\u5c31\u662f\u5728\u670d\u52a1\u5668\u76d1\u542c\u7aef\u53e3\uff0c\u901a\u8fc7\u4e00\u5b9a\u7684\u534f\u8bae\u4ea4\u4e92\u6765\u5199\u5165\u6570\u636e\u5230\u670d\u52a1\u5668\u5185\u5b58\u4e2d\uff0c\u6216\u8005\u83b7\u53d6\u4e00\u4e9b\u503c\u3002\u5982\u679c\u4f60\u4e86\u89e3Memcache\u7684\u4ea4\u4e92\u534f\u8bae\uff0c\u5b8c\u5168\u53ef\u4ee5\u81ea\u5df1\u6784\u5efaMemcache\u7684\u5ba2\u6237\u7aef\uff0c\u76ee\u524d\u7f51\u4e0a\u4e5f\u6709\u5f88\u591a\u6784\u5efa\u597d\u7684Memcache\u5ba2\u6237\u7aef\u7684PHP Class\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528\uff0c\u4e0d\u8fc7\u6211\u8fd9\u91cc\u4e3a\u4e86\u6548\u7387\uff0c\u8fd8\u662f\u51b3\u5b9a\u4f7f\u7528PECL\u4e2dMemcache\u7684\u4e13\u7528\u6269\u5c55\uff0c\u56e0\u4e3a\u6bd5\u7adf\u662f\u7528C\u5199\u7684\uff0c\u6548\u7387\u6bd4\u8f83\u9ad8\uff0c\u800c\u4e14\u5b89\u88c5\u90e8\u7f72\u6bd4\u8f83\u65b9\u4fbf\u3002<\/P><br \/>\n<P>\u4e0b\u8f7dPECL\u4e2d\u7684Memcache\uff0c\u56e0\u4e3a\u6211\u7684\u5ba2\u6237\u7aef\u662fWindows XP\uff0c\u6240\u4ee5\u9700\u8981\u4e0b\u8f7ddll\u7248\uff0c\u6211\u7684PHP\u7248\u672c\u662fPHP 5.1.4\uff0c\u5fc5\u987b\u4e0b\u8f7dPHP 5.1\u4e13\u7528\u7684\u6269\u5c55\u3002<BR>PECL\u5b98\u7f51\uff1a<A href=\"http:\/\/pecl.php.net\/\"><EM>http:\/\/pecl.php.net<\/EM><\/A><EM> \uff08For Linux\uff09<\/EM><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href=\"http:\/\/pecl4win.php.net\/\"><EM>http:\/\/pecl4win.php.net<\/EM><\/A><EM>\uff08For Windows\uff09<\/EM><BR>\u6269\u5c55\u4e0b\u8f7d\uff1a <A href=\"http:\/\/pecl4win.php.net\/download.php\/ext\/5_1\/5.1.2\/php_memcache.dll\"><EM>http:\/\/pecl4win.php.net\/download.php\/ext\/5_1\/5.1.2\/php_memcache.dll<\/EM><\/A><\/P><br \/>\n<P>\u5982\u679c\u4f60\u7684PHP\u662f\u5176\u4ed6\u7248\u672c\uff0c\u8bf7\u5230 <A href=\"http:\/\/pecl4win.php.net\/ext.php\/php_memcache.dll\"><EM>http:\/\/pecl4win.php.net\/ext.php\/php_memcache.dll<\/EM><\/A> \u9009\u62e9\u4f60\u76f8\u5e94\u7684\u7248\u672c\uff0c\u5982\u679c\u662fLinux\u4e0b\u7684PHP\uff0c\u8bf7\u5230 <A href=\"http:\/\/pecl.php.net\/package\/memcache\"><EM>http:\/\/pecl.php.net\/package\/memcache<\/EM><\/A>&nbsp;\u9009\u62e9\u76f8\u5e94\u60f3\u8981\u4e0b\u8f7d\u7684\u7248\u672c\u3002<\/P><br \/>\n<P>\u4e0b\u8f7d\u5b8c\u4e86\u4ee5\u540e\uff0c\u6211\u628aphp_memcache.dll \u62f7\u8d1d\u5230 <FONT color=#993300>c:\\php5\\ext<\/FONT> \u76ee\u5f55\u4e0b\uff0c\u5982\u679c\u4f60\u7684\u6269\u5c55\u76ee\u5f55\u662f\u5728\u662f\u7f3a\u7701\u8def\u5f84\uff0c\uff08\u5c31\u662f\u6ca1\u6709\u4fee\u6539\u8fc7php.ini\u4e2d\u7684\u6269\u5c55\u8def\u5f84\uff09 \u8bf7\u62f7\u8d1d\u5230 <FONT color=#993300>c:\\windows\\<\/FONT> \u76ee\u5f55\u4e0b\uff0c\u5982\u679c\u662fLinux\u5e73\u53f0\uff0c\u8bf7\u81ea\u5df1\u7f16\u8bd1\u5b89\u88c5\uff0c\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528dl()\u51fd\u6570\u52a0\u8f7d\uff0c\u6216\u8005\u5728\u7f16\u8bd1php\u7684\u65f6\u5019\u52a0\u8f7d\u8fdb\u53bb\u3002\u6700\u540e\u91cd\u542fWeb\u670d\u52a1\u5668\uff0cIIS\/Apache\u3002<\/P><br \/>\n<P>\u6211\u7684\u7f51\u7ad9\u76ee\u5f55\u662f\u5728\uff1a<FONT color=#993300>d:\\mysite<\/FONT> \u76ee\u5f55\u4e0b\uff0c\u73b0\u5728\u5efa\u7acb\u4e00\u4e2a <FONT color=#993300>phpinfo.php<\/FONT> \u6587\u4ef6\u5728\u7f51\u7ad9\u6839\u76ee\u5f55\u4e0b\uff0c\u4ee3\u7801\u662f\uff1a<BR><FONT color=#0000ff>&lt;?phpinfo()?&gt;<\/FONT><BR>\u770b\u6709\u6ca1\u6709\u6210\u529f\u52a0\u8f7d <FONT color=#993300>php_memcache.dll<\/FONT> \u6269\u5c55\u3002\u5982\u679c\u663e\u793a\u4e86 Memcache \u9009\u9879\u548c\u76f8\u5e94\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8bf4\u660e\u6210\u529f\u52a0\u8f7d\u4e86\uff0c\u5426\u5219\u8bf7\u4ed4\u7ec6\u68c0\u67e5\u4e0a\u9762\u7684\u6b65\u9aa4\u3002<\/P><br \/>\n<P>\u5982\u679c\u4e00\u5207\u6b63\u786e\u65e0\u8bef\uff0c\u90a3\u4e48\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><FONT size=4><STRONG>\u3010Memcache\u521d\u8bd5\u3011<\/STRONG><\/FONT><\/P><br \/>\n<P><STRONG><FONT size=2>[ \u63a5\u53e3\u4ecb\u7ecd ]<\/FONT><\/STRONG><BR>\u670d\u52a1\u5668\u7aef\u548c\u5ba2\u6237\u7aef\u90fd\u5b89\u88c5\u914d\u7f6e\u597d\u4e86\uff0c\u73b0\u5728\u6211\u4eec\u5c31\u6765\u6d4b\u8bd5\u4ee5\u4e0b\u6211\u4eec\u7684\u6210\u679c\u3002Memcache\u5ba2\u6237\u7aef\u5305\u542b\u4e24\u7ec4\u63a5\u53e3\uff0c\u4e00\u7ec4\u662f\u9762\u5411\u8fc7\u7a0b\u7684\u63a5\u53e3\uff0c\u4e00\u7ec4\u662f\u9762\u5411\u5bf9\u8c61\u7684\u63a5\u53e3\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003PHP\u624b\u518c \u201cLXXV. Memcache Functions\u201d \u8fd9\u7ae0\u3002\u6211\u4eec\u4e3a\u4e86\u7b80\u5355\u65b9\u4fbf\uff0c\u5c31\u4f7f\u7528\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\uff0c\u4e5f\u4fbf\u4e8e\u7ef4\u62a4\u548c\u7f16\u5199\u4ee3\u7801\u3002Memcache\u9762\u5411\u5bf9\u8c61\u7684\u5e38\u7528\u63a5\u53e3\u5305\u62ec\uff1a<\/P><br \/>\n<P><FONT color=#993300>Memcache::connect &#8212; \u6253\u5f00\u4e00\u4e2a\u5230Memcache\u7684\u8fde\u63a5<BR>Memcache::pconnect &#8212; \u6253\u5f00\u4e00\u4e2a\u5230Memcache\u7684\u957f\u8fde\u63a5<BR>Memcache::close &#8212; \u5173\u95ed\u4e00\u4e2aMemcache\u7684\u8fde\u63a5<BR>Memcache::set &#8212; \u4fdd\u5b58\u6570\u636e\u5230Memcache\u670d\u52a1\u5668\u4e0a<BR>Memcache::get &#8212; \u63d0\u53d6\u4e00\u4e2a\u4fdd\u5b58\u5728Memcache\u670d\u52a1\u5668\u4e0a\u7684\u6570\u636e<BR>Memcache::replace &#8212; \u66ff\u6362\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728Memcache\u670d\u52a1\u5668\u4e0a\u7684\u9879\u76ee\uff08\u529f\u80fd\u7c7b\u4f3cMemcache::set\uff09<BR>Memcache::delete &#8212; \u4eceMemcache\u670d\u52a1\u5668\u4e0a\u5220\u9664\u4e00\u4e2a\u4fdd\u5b58\u7684\u9879\u76ee<BR>Memcache::flush &#8212; \u5237\u65b0\u6240\u6709Memcache\u670d\u52a1\u5668\u4e0a\u4fdd\u5b58\u7684\u9879\u76ee\uff08\u7c7b\u4f3c\u4e8e\u5220\u9664\u6240\u6709\u7684\u4fdd\u5b58\u7684\u9879\u76ee\uff09<BR>Memcache::getStats &#8212; \u83b7\u53d6\u5f53\u524dMemcache\u670d\u52a1\u5668\u8fd0\u884c\u7684\u72b6\u6001<\/FONT><\/P><br \/>\n<P><STRONG><FONT size=2>[ \u6d4b\u8bd5\u4ee3\u7801 ]<\/FONT><\/STRONG><BR>\u73b0\u5728\u6211\u4eec\u5f00\u59cb\u4e00\u6bb5\u6d4b\u8bd5\u4ee3\u7801\uff1a<BR><\/P><br \/>\n<DIV style=\"BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid\"><br \/>\n<DIV><SPAN style=\"COLOR: #000000\">&lt;?<\/SPAN><SPAN style=\"COLOR: #000000\">php<BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u8fde\u63a5<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">new<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;Memcache;<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">connect(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">192.168.0.200<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">12000<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u4fdd\u5b58\u6570\u636e<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">set(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key1<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">This&nbsp;is&nbsp;first&nbsp;value<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">60<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$val<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">get(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key1<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Get&nbsp;key1&nbsp;value:&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">.<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$val<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">.<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;br&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u66ff\u6362\u6570\u636e<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">replace(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key1<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">This&nbsp;is&nbsp;replace&nbsp;value<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">60<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$val<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">get(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key1<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Get&nbsp;key1&nbsp;value:&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">.<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$val<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">.<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;br&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u4fdd\u5b58\u6570\u7ec4<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$arr<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">array<\/SPAN><SPAN style=\"COLOR: #000000\">(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">aaa<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">bbb<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">ccc<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">ddd<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">set(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key2<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$arr<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\">,<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">60<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$val2<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">get(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key2<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Get&nbsp;key2&nbsp;value:&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><\/SPAN><SPAN style=\"COLOR: #008080\">print_r<\/SPAN><SPAN style=\"COLOR: #000000\">(<\/SPAN><SPAN style=\"COLOR: #800080\">$val2<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;br&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u5220\u9664\u6570\u636e<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">delete(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key1<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$val<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">get(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key1<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Get&nbsp;key1&nbsp;value:&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">.<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$val<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">.<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;br&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u6e05\u9664\u6240\u6709\u6570\u636e<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #008080\">flush<\/SPAN><SPAN style=\"COLOR: #000000\">();<BR><\/SPAN><SPAN style=\"COLOR: #800080\">$val2<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">get(<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">key2<\/SPAN><SPAN style=\"COLOR: #000000\">&#8216;<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Get&nbsp;key2&nbsp;value:&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><\/SPAN><SPAN style=\"COLOR: #008080\">print_r<\/SPAN><SPAN style=\"COLOR: #000000\">(<\/SPAN><SPAN style=\"COLOR: #800080\">$val2<\/SPAN><SPAN style=\"COLOR: #000000\">);<BR><\/SPAN><SPAN style=\"COLOR: #0000ff\">echo<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;br&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">;<BR><BR><\/SPAN><SPAN style=\"COLOR: #008000\">\/\/<\/SPAN><SPAN style=\"COLOR: #008000\">\u5173\u95ed\u8fde\u63a5<\/SPAN><SPAN style=\"COLOR: #008000\"><BR><\/SPAN><SPAN style=\"COLOR: #800080\">$mem<\/SPAN><SPAN style=\"COLOR: #000000\">-&gt;<\/SPAN><SPAN style=\"COLOR: #000000\">close();<BR><\/SPAN><SPAN style=\"COLOR: #000000\">?&gt;<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><BR><\/SPAN><\/DIV><\/DIV><br \/>\n<P><BR>\u5982\u679c\u6b63\u5e38\u7684\u8bdd\uff0c\u6d4f\u89c8\u5668\u5c06\u8f93\u51fa\uff1a<BR><FONT color=#993300>Get key1 value: This is first value<BR>Get key1 value: This is replace value<BR>Get key2 value: Array ( [0] =&gt; aaa [1] =&gt; bbb [2] =&gt; ccc [3] =&gt; ddd ) <BR>Get key1 value: <BR>Get key2 value:<\/FONT> <\/P><br \/>\n<P><BR>\u57fa\u672c\u8bf4\u660e\u6211\u4eec\u7684Memcache\u5b89\u88c5\u6210\u529f\uff0c\u6211\u4eec\u518d\u6765\u5206\u6790\u4ee5\u4e0b\u4e0a\u9762\u7684\u8fd9\u6bb5\u7a0b\u5e8f\u3002<\/P><br \/>\n<P><BR><STRONG><FONT size=2>[ \u7a0b\u5e8f\u5206\u6790 ]<\/FONT><\/STRONG><\/P><br \/>\n<P>\u521d\u59cb\u5316\u4e00\u4e2aMemcache\u7684\u5bf9\u8c61\uff1a<BR><FONT color=#0000ff><FONT color=#993300>$mem<\/FONT> = new <FONT color=#000000>Memcache<\/FONT>;<\/FONT><\/P><br \/>\n<P>\u8fde\u63a5\u5230\u6211\u4eec\u7684Memcache\u670d\u52a1\u5668\u7aef\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u670d\u52a1\u5668\u7684IP\u5730\u5740\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e3b\u673a\u540d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662fMemcache\u7684\u5f00\u653e\u7684\u7aef\u53e3\uff1a<BR><FONT color=#0000ff><FONT color=#993300>$mem-&gt;<\/FONT>connect(<FONT color=#339966>&#8220;192.168.0.200&#8221;<\/FONT>, <FONT color=#ff0000>12000<\/FONT>);<\/FONT><\/P><br \/>\n<P>\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5230Memcache\u670d\u52a1\u5668\u4e0a\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u6570\u636e\u7684key\uff0c\u7528\u6765\u5b9a\u4f4d\u4e00\u4e2a\u6570\u636e\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u9700\u8981\u4fdd\u5b58\u7684\u6570\u636e\u5185\u5bb9\uff0c\u8fd9\u91cc\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u4e00\u4e2a\u6807\u8bb0\uff0c\u4e00\u822c\u8bbe\u7f6e\u4e3a0\u6216\u8005MEMCACHE_COMPRESSED\u5c31\u884c\u4e86\uff0c\u7b2c\u56db\u4e2a\u53c2\u6570\u662f\u6570\u636e\u7684\u6709\u6548\u671f\uff0c\u5c31\u662f\u8bf4\u6570\u636e\u5728\u8fd9\u4e2a\u65f6\u95f4\u5185\u662f\u6709\u6548\u7684\uff0c\u5982\u679c\u8fc7\u53bb\u8fd9\u4e2a\u65f6\u95f4\uff0c\u90a3\u4e48\u4f1a\u88abMemcache\u670d\u52a1\u5668\u7aef\u6e05\u9664\u6389\u8fd9\u4e2a\u6570\u636e\uff0c\u5355\u4f4d\u662f\u79d2\uff0c\u5982\u679c\u8bbe\u7f6e\u4e3a0\uff0c\u5219\u662f\u6c38\u8fdc\u6709\u6548\uff0c\u6211\u4eec\u8fd9\u91cc\u8bbe\u7f6e\u4e8660\uff0c\u5c31\u662f\u4e00\u5206\u949f\u6709\u6548\u65f6\u95f4\uff1a<BR><FONT color=#0000ff><FONT color=#993300>$mem<\/FONT>-&gt;set(<FONT color=#339966>&#8216;key1<\/FONT>&#8216;, <FONT color=#339966>&#8216;This is first value&#8217;<\/FONT>, <FONT color=#ff0000>0<\/FONT>, <FONT color=#ff0000>60<\/FONT>);<\/FONT><\/P><br \/>\n<P>\u4eceMemcache\u670d\u52a1\u5668\u7aef\u83b7\u53d6\u4e00\u6761\u6570\u636e\uff0c\u5b83\u53ea\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u5c31\u662f\u9700\u8981\u83b7\u53d6\u6570\u636e\u7684key\uff0c\u6211\u4eec\u8fd9\u91cc\u662f\u4e0a\u4e00\u6b65\u8bbe\u7f6e\u7684key1\uff0c\u73b0\u5728\u83b7\u53d6\u8fd9\u4e2a\u6570\u636e\u540e\u8f93\u51fa\u8f93\u51fa\uff1a<BR><FONT color=#0000ff><FONT color=#993300>$val<\/FONT> = <FONT color=#993300>$mem<\/FONT>-&gt;get(&#8216;<FONT color=#339966>key1&#8242;<\/FONT>);<BR>echo <FONT color=#339966>&#8220;Get key1 value: &#8220;<\/FONT> . <\/FONT><FONT color=#993300>$val;<\/FONT><\/P><br \/>\n<P>\u73b0\u5728\u662f\u4f7f\u7528replace\u65b9\u6cd5\u6765\u66ff\u6362\u6389\u4e0a\u9762key1\u7684\u503c\uff0creplace\u65b9\u6cd5\u7684\u53c2\u6570\u8ddfset\u662f\u4e00\u6837\u7684\uff0c\u4e0d\u8fc7\u7b2c\u4e00\u4e2a\u53c2\u6570key1\u662f\u5fc5\u987b\u662f\u8981\u66ff\u6362\u6570\u636e\u5185\u5bb9\u7684key\uff0c\u6700\u540e\u8f93\u51fa\u4e86\uff1a<BR><FONT color=#0000ff><FONT color=#993300>$mem<\/FONT>-&gt;replace(<FONT color=#339966>&#8216;key1&#8217;<\/FONT>, <FONT color=#339966>&#8216;This is replace value&#8217;<\/FONT>, <FONT color=#ff0000>0<\/FONT>, <FONT color=#ff0000>60<\/FONT>);<BR><FONT color=#993300>$val<\/FONT> = <FONT color=#993300>$mem<\/FONT>-&gt;get(<FONT color=#339966>&#8216;key1&#8217;<\/FONT>);<BR>echo &#8220;<FONT color=#339966>Get key1 value:<\/FONT> &#8221; . <FONT color=#993300>$val<\/FONT>;<\/FONT><\/P><br \/>\n<P>\u540c\u6837\u7684\uff0cMemcache\u4e5f\u662f\u53ef\u4ee5\u4fdd\u5b58\u6570\u7ec4\u7684\uff0c\u4e0b\u9762\u662f\u5728Memcache\u4e0a\u9762\u4fdd\u5b58\u4e86\u4e00\u4e2a\u6570\u7ec4\uff0c\u7136\u540e\u83b7\u53d6\u56de\u6765\u5e76\u8f93\u51fa<BR><FONT color=#0000ff><FONT color=#993300>$arr<\/FONT> = array(<FONT color=#339966>&#8216;aaa&#8217;,<\/FONT> <FONT color=#339966>&#8216;bbb&#8217;,<\/FONT> <FONT color=#339966>&#8216;ccc&#8217;<\/FONT>, <FONT color=#339966>&#8216;ddd&#8217;<\/FONT>);<BR><FONT color=#993300>$mem<\/FONT>-&gt;set(<FONT color=#339966>&#8216;key2&#8217;<\/FONT>, <FONT color=#ff0000>$arr<\/FONT>, <FONT color=#ff0000>0<\/FONT>, <FONT color=#ff0000>60<\/FONT>);<BR><FONT color=#993300>$val2<\/FONT> = <FONT color=#993300>$mem<\/FONT>-&gt;get(<FONT color=#339966>&#8216;key2&#8217;<\/FONT>);<BR>print_r(<FONT color=#993300>$val2<\/FONT>);<\/FONT><\/P><br \/>\n<P>\u73b0\u5728\u5220\u9664\u4e00\u4e2a\u6570\u636e\uff0c\u4f7f\u7528delte\u63a5\u53e3\uff0c\u53c2\u6570\u5c31\u662f\u4e00\u4e2akey\uff0c\u7136\u540e\u5c31\u80fd\u591f\u628aMemcache\u670d\u52a1\u5668\u8fd9\u4e2akey\u7684\u6570\u636e\u5220\u9664\uff0c\u6700\u540e\u8f93\u51fa\u7684\u65f6\u5019\u6ca1\u6709\u7ed3\u679c<BR><FONT color=#0000ff>$<FONT color=#993300>mem<\/FONT>-&gt;delete(<FONT color=#339966>&#8216;key1&#8217;<\/FONT>);<BR>$<FONT color=#993300>val<\/FONT> = $<FONT color=#993300>mem<\/FONT>-&gt;get(<FONT color=#339966>&#8216;key1&#8217;<\/FONT>);<BR>echo &#8220;<FONT color=#339966>Get key1 value:<\/FONT> &#8221; . $<FONT color=#993300>val<\/FONT> . <\/FONT><FONT color=#339966>&#8220;&lt;br&gt;&#8221;;<\/FONT><\/P><br \/>\n<P>\u6700\u540e\u6211\u4eec\u628a\u6240\u6709\u7684\u4fdd\u5b58\u5728Memcache\u670d\u52a1\u5668\u4e0a\u7684\u6570\u636e\u90fd\u6e05\u9664\uff0c\u4f1a\u53d1\u73b0\u6570\u636e\u90fd\u6ca1\u6709\u4e86\uff0c\u6700\u540e\u8f93\u51fakey2\u7684\u6570\u636e\u4e3a\u7a7a\uff0c\u6700\u540e\u5173\u95ed\u8fde\u63a5<BR><FONT color=#0000ff>$<FONT color=#993300>mem<\/FONT>-&gt;flush();<BR>$<FONT color=#993300>val2<\/FONT> = $<FONT color=#993300>mem<\/FONT>-&gt;get(<FONT color=#339966>&#8216;key2&#8217;<\/FONT>);<BR>echo &#8220;<FONT color=#339966>Get key2 value:<\/FONT> &#8220;;<BR>print_r(<FONT color=#993300>$val2<\/FONT>);<BR>echo <\/FONT><FONT color=#339966>&#8220;&lt;br&gt;&#8221;;<\/FONT><\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><BR><STRONG><FONT size=4>\u3010Memcache\u534f\u8bae\u5206\u6790\u3011<\/FONT><\/STRONG><\/P><br \/>\n<P>\u5982\u679c\u4f60\u4e0d\u559c\u6b22 <FONT color=#993300>php_memcache.dll <\/FONT>\u6269\u5c55\u6216\u8005\u670d\u52a1\u5668\u5668\u76ee\u524d\u4e0d\u652f\u6301\u8fd9\u4e2a\u6269\u5c55\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u8003\u8651\u81ea\u5df1\u6784\u5efa\uff0c\u9700\u8981\u6784\u5efaMemcahe\u7684\u5ba2\u6237\u7aef\uff0c\u8981\u5148\u4e86\u89e3Memcache\u534f\u8bae\u7684\u4ea4\u4e92\uff0c\u8fd9\u6837\u624d\u80fd\u5f00\u53d1\u81ea\u5df1\u7684\u5ba2\u6237\u7aef\uff0c\u6211\u8fd9\u91cc\u5c31\u7b80\u5355\u7684\u5206\u6790\u4ee5\u4e0bMemcache\u7684\u534f\u8bae\u3002<BR>\uff08\u66f4\u8be6\u7ec6\u7684\u534f\u8bae\u5185\u5bb9\u8bf7\u5728Memcache\u670d\u52a1\u5668\u7aef\u7684\u6e90\u7801\u7684 doc\/protocol.txt \u6587\u4ef6\u4e2d\uff0c\u672c\u6587\u57fa\u672c\u6765\u6e90\u4e8e\u6b64\uff09<\/P><br \/>\n<P>Memcache\u65e2\u652f\u6301TCP\u534f\u8bae\uff0c\u4e5f\u652f\u6301UDP\u534f\u8bae\uff0c\u4e0d\u8fc7\u6211\u4eec\u8fd9\u91cc\u662f\u4ee5TCP\u534f\u8bae\u7684\u534f\u8bae\u4f5c\u4e3a\u4e3b\u8981\u8003\u8651\u5bf9\u8c61\uff0c\u60f3\u4e86\u89e3UDP\u534f\u8bae\u7684\u8fc7\u7a0b\uff0c\u8bf7\u53c2\u8003 doc\/protocol.txt \u6587\u4ef6\u3002<\/P><br \/>\n<P><STRONG><FONT size=2>[ \u9519\u8bef\u6307\u4ee4]<\/FONT><\/STRONG><BR>Memcache\u7684\u534f\u8bae\u7684\u9519\u8bef\u90e8\u5206\u4e3b\u8981\u662f\u4e09\u4e2a\u9519\u8bef\u63d0\u793a\u4e4b\u63d0\u793a\u6307\u4ee4\uff1a<BR>\u666e\u901a\u9519\u8bef\u4fe1\u606f\uff0c\u6bd4\u5982\u6307\u4ee4\u9519\u8bef\u4e4b\u7c7b\u7684<BR><FONT color=#0000ff>ERROR<\/FONT><FONT color=#000000>\\r\\n<\/FONT><\/P><br \/>\n<P>\u5ba2\u6237\u7aef\u9519\u8bef<BR><FONT color=#0000ff>CLIENT_ERROR<\/FONT> <FONT color=#993300>&lt;\u9519\u8bef\u4fe1\u606f&gt;<\/FONT>\\r\\n<\/P><br \/>\n<P>\u670d\u52a1\u5668\u7aef\u9519\u8bef<BR><FONT color=#0000ff>SERVER_ERROR<\/FONT> <FONT color=#993300>&lt;\u9519\u8bef\u4fe1\u606f&gt;<\/FONT>\\r\\n<\/P><br \/>\n<P><STRONG><FONT size=2>[ \u6570\u636e\u4fdd\u5b58\u6307\u4ee4]<\/FONT><\/STRONG><BR>\u6570\u636e\u4fdd\u5b58\u662f\u57fa\u672c\u7684\u529f\u80fd\uff0c\u5c31\u662f\u5ba2\u6237\u7aef\u901a\u8fc7\u547d\u4ee4\u628a\u6570\u636e\u8fd4\u56de\u8fc7\u6765\uff0c\u670d\u52a1\u5668\u7aef\u63a5\u6536\u540e\u8fdb\u884c\u5904\u7406\u3002<BR>\u6307\u4ee4\u683c\u5f0f\uff1a<BR><FONT color=#993300>&lt;\u547d\u4ee4&gt; &lt;\u952e&gt; &lt;\u6807\u8bb0&gt; &lt;\u6709\u6548\u671f&gt; &lt;\u6570\u636e\u957f\u5ea6&gt;<\/FONT>\\r\\n<\/P><br \/>\n<P><STRONG>&lt;\u547d\u4ee4&gt;<\/STRONG> &#8211; <FONT color=#993300>command name <BR><\/FONT>\u4e3b\u8981\u662f\u4e09\u4e2a\u50a8\u5b58\u6570\u636e\u7684\u4e09\u4e2a\u547d\u4ee4\uff0c set, add, replace<BR><FONT color=#0000ff>set<\/FONT> \u547d\u4ee4\u662f\u4fdd\u5b58\u4e00\u4e2a\u53eb\u505akey\u7684\u6570\u636e\u5230\u670d\u52a1\u5668\u4e0a<BR><FONT color=#0000ff>add<\/FONT> \u547d\u4ee4\u662f\u6dfb\u52a0\u4e00\u4e2a\u6570\u636e\u5230\u670d\u52a1\u5668\uff0c\u4f46\u662f\u670d\u52a1\u5668\u5fc5\u987b\u8fd9\u4e2akey\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u80fd\u591f\u4fdd\u8bc1\u6570\u636e\u4e0d\u4f1a\u88ab\u8986\u76d6<BR><FONT color=#0000ff>replace<\/FONT> \u547d\u4ee4\u662f\u66ff\u6362\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u6570\u636e\uff0c\u5982\u679c\u6570\u636e\u4e0d\u5b58\u5728\uff0c\u5c31\u662f\u7c7b\u4f3cset\u529f\u80fd<\/P><br \/>\n<P><STRONG>&lt;\u952e&gt;<\/STRONG> &#8211; <FONT color=#993300>key<\/FONT><BR>\u5c31\u662f\u4fdd\u5b58\u5728\u670d\u52a1\u5668\u4e0a\u552f\u4e00\u7684\u4e00\u4e2a\u8868\u793a\u7b26\uff0c\u5fc5\u987b\u662f\u8ddf\u5176\u4ed6\u7684key\u4e0d\u51b2\u7a81\uff0c\u5426\u5219\u4f1a\u8986\u76d6\u6389\u539f\u6765\u7684\u6570\u636e\uff0c\u8fd9\u4e2akey\u662f\u4e3a\u4e86\u80fd\u591f\u51c6\u786e\u7684\u5b58\u53d6\u4e00\u4e2a\u6570\u636e\u9879\u76ee<\/P><br \/>\n<P><STRONG>&lt;\u6807\u8bb0&gt;<\/STRONG> &#8211; <FONT color=#993300>flag<\/FONT><BR>\u6807\u8bb0\u662f\u4e00\u4e2a16\u4f4d\u7684\u65e0\u7b26\u53f7\u6574\u5f62\u6570\u636e\uff0c\u7528\u6765\u8bbe\u7f6e\u670d\u52a1\u5668\u7aef\u8ddf\u5ba2\u6237\u7aef\u4e00\u4e9b\u4ea4\u4e92\u7684\u64cd\u4f5c<\/P><br \/>\n<P><STRONG>&lt;\u6709\u6548\u671f&gt;<\/STRONG> &#8211; <FONT color=#993300>expiration time<\/FONT><BR>\u662f\u6570\u636e\u5728\u670d\u52a1\u5668\u4e0a\u7684\u6709\u6548\u671f\u9650\uff0c\u5982\u679c\u662f0\uff0c\u5219\u6570\u636e\u6c38\u8fdc\u6709\u6548\uff0c\u5355\u4f4d\u662f\u79d2\uff0cMemcache\u670d\u52a1\u5668\u7aef\u4f1a\u628a\u4e00\u4e2a\u6570\u636e\u7684\u6709\u6548\u671f\u8bbe\u7f6e\u4e3a\u5f53\u524dUnix\u65f6\u95f4+\u8bbe\u7f6e\u7684\u6709\u6548\u65f6\u95f4<\/P><br \/>\n<P><STRONG>&lt;\u6570\u636e\u957f\u5ea6&gt;<\/STRONG> &#8211; <FONT color=#993300>bytes<\/FONT><BR>\u6570\u636e\u7684\u957f\u5ea6\uff0cblock data \u5757\u6570\u636e\u7684\u957f\u5ea6\uff0c\u4e00\u822c\u5728\u8fd9\u4e2a\u4e2a\u957f\u5ea6\u7ed3\u675f\u4ee5\u540e\u4e0b\u4e00\u884c\u8ddf\u7740block data\u6570\u636e\u5185\u5bb9\uff0c\u53d1\u9001\u5b8c\u6570\u636e\u4ee5\u540e\uff0c\u5ba2\u6237\u7aef\u4e00\u822c\u7b49\u5f85\u670d\u52a1\u5668\u7aef\u7684\u8fd4\u56de\uff0c\u670d\u52a1\u5668\u7aef\u7684\u8fd4\u56de\uff1a<\/P><br \/>\n<P>\u6570\u636e\u4fdd\u5b58\u6210\u529f<BR><FONT color=#0000ff>STORED<\/FONT>\\r\\n<\/P><br \/>\n<P>\u6570\u636e\u4fdd\u5b58\u5931\u8d25\uff0c\u4e00\u822c\u662f\u56e0\u4e3a\u670d\u52a1\u5668\u7aef\u8fd9\u4e2a\u6570\u636ekey\u5df2\u7ecf\u5b58\u5728\u4e86<BR><FONT color=#0000ff>NOT_STORED<\/FONT>\\r\\n<\/P><br \/>\n<P><BR><STRONG><FONT size=2>[ \u6570\u636e\u63d0\u53d6\u547d\u4ee4]<\/FONT><\/STRONG><BR>\u4ece\u670d\u52a1\u5668\u7aef\u63d0\u53d6\u6570\u636e\u4e3b\u8981\u662f\u4f7f\u7528get\u6307\u4ee4\uff0c\u683c\u5f0f\u662f\uff1a<BR><FONT color=#0000ff>get<\/FONT> <FONT color=#993300>&lt;\u952e&gt;*<\/FONT>\\r\\n<\/P><br \/>\n<P><STRONG>&lt;\u952e&gt;*<\/STRONG> &#8211; <FONT color=#993300>key<\/FONT><BR><FONT color=#993300>key<\/FONT>\u662f\u662f\u4e00\u4e2a\u4e0d\u4e3a\u7a7a\u7684\u5b57\u7b26\u4e32\u7ec4\u5408\uff0c\u53d1\u9001\u8fd9\u4e2a\u6307\u4ee4\u4ee5\u540e\uff0c\u7b49\u5f85\u670d\u52a1\u5668\u7684\u8fd4\u56de\u3002\u5982\u679c\u670d\u52a1\u5668\u7aef\u6ca1\u6709\u4efb\u4f55\u6570\u636e\uff0c\u5219\u662f\u8fd4\u56de\uff1a<BR><FONT color=#0000ff>END<\/FONT>\\r\\n<\/P><br \/>\n<P>\u8bc1\u660e\u6ca1\u6709\u4e0d\u5b58\u5728\u8fd9\u4e2akey\uff0c\u6ca1\u6709\u4efb\u4f55\u6570\u636e\uff0c\u5982\u679c\u5b58\u5728\u6570\u636e\uff0c\u5219\u8fd4\u56de\u6307\u5b9a\u683c\u5f0f\uff1a<BR><FONT color=#0000ff>VALUE<\/FONT> &lt;<FONT color=#993300>\u952e<\/FONT>&gt; &lt;<FONT color=#993300>\u6807\u8bb0<\/FONT>&gt; &lt;<FONT color=#993300>\u6570\u636e\u957f\u5ea6<\/FONT>&gt;\\r\\n<BR><STRONG>&lt;\u6570\u636e\u5757&gt;<\/STRONG>\\r\\n<\/P><br \/>\n<P>\u8fd4\u56de\u7684\u6570\u636e\u662f\u4ee5<FONT color=#993300>VALUE<\/FONT>\u5f00\u59cb\u7684\uff0c\u540e\u9762\u8ddf\u7740key\u548cflags\uff0c\u4ee5\u53ca\u6570\u636e\u957f\u5ea6\uff0c\u7b2c\u4e8c\u884c\u8ddf\u7740\u6570\u636e\u5757\u3002<\/P><br \/>\n<P><STRONG>&lt;\u952e&gt;<\/STRONG> -key <BR>\u662f\u53d1\u9001\u8fc7\u6765\u6307\u4ee4\u7684key\u5185\u5bb9<\/P><br \/>\n<P><STRONG>&lt;\u6807\u8bb0&gt;<\/STRONG> &#8211; flags<BR>\u662f\u8c03\u7528set\u6307\u4ee4\u4fdd\u5b58\u6570\u636e\u65f6\u5019\u7684flags\u6807\u8bb0<\/P><br \/>\n<P><STRONG>&lt;\u6570\u636e\u957f\u5ea6&gt;<\/STRONG> &#8211; bytes<BR>\u662f\u4fdd\u5b58\u6570\u636e\u65f6\u5019\u5b9a\u4f4d\u7684\u957f\u5ea6<\/P><br \/>\n<P><STRONG>&lt;\u6570\u636e\u5757&gt;<\/STRONG> &#8211; data block<BR>\u6570\u636e\u957f\u5ea6\u4e0b\u4e00\u884c\u5c31\u662f\u63d0\u53d6\u7684\u6570\u636e\u5757\u5185\u5bb9<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><FONT size=2><STRONG>[ \u6570\u636e\u5220\u9664\u6307\u4ee4]<\/STRONG><\/FONT><BR>\u6570\u636e\u5220\u9664\u6307\u4ee4\u4e5f\u662f\u6bd4\u8f83\u7b80\u5355\u7684\uff0c\u4f7f\u7528get\u6307\u4ee4\uff0c\u683c\u5f0f\u662f\uff1a<BR>delete &lt;\u952e&gt; &lt;\u8d85\u65f6\u65f6\u95f4&gt;\\r\\n<\/P><br \/>\n<P><STRONG>&lt;\u952e&gt;<\/STRONG> &#8211; key<BR>key\u662f\u4f60\u5e0c\u671b\u5728\u670d\u52a1\u5668\u4e0a\u5220\u9664\u6570\u636e\u7684key\u952e<\/P><br \/>\n<P><STRONG>&lt;\u8d85\u65f6\u65f6\u95f4&gt;<\/STRONG> &#8211; timeout<BR>\u6309\u7167\u79d2\u4e3a\u5355\u4f4d\uff0c\u8fd9\u4e2a\u662f\u4e2a\u53ef\u9009\u9879\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u6307\u5b9a\u8fd9\u4e2a\u503c\uff0c\u90a3\u4e48\u670d\u52a1\u5668\u4e0akey\u6570\u636e\u5c06\u9a6c\u4e0a\u88ab\u5220\u9664\uff0c\u5982\u679c\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\u503c\uff0c\u90a3\u4e48\u6570\u636e\u5c06\u5728\u8d85\u65f6\u65f6\u95f4\u540e\u628a\u6570\u636e\u6e05\u9664\uff0c\u8be5\u9879\u7f3a\u7701\u503c\u662f0\uff0c\u5c31\u662f\u9a6c\u4e0a\u88ab\u5220\u9664<\/P><br \/>\n<P>\u5220\u9664\u6570\u636e\u540e\uff0c\u670d\u52a1\u5668\u7aef\u4f1a\u8fd4\u56de\uff1a<BR><FONT color=#0000ff>DELETED<\/FONT>\\r\\n<BR>\u5220\u9664\u6570\u636e\u6210\u529f<BR><FONT color=#0000ff>NOT_FOUND<\/FONT>\\r\\n<BR>\u8fd9\u4e2akey\u6ca1\u6709\u5728\u670d\u52a1\u5668\u4e0a\u627e\u5230<\/P><br \/>\n<P>\u5982\u679c\u8981\u5220\u9664\u6240\u6709\u670d\u52a1\u5668\u4e0a\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528flash_all\u6307\u4ee4\uff0c\u683c\u5f0f\uff1a<BR><FONT color=#0000ff>flush_all<\/FONT>\\r\\n<BR><BR>\u8fd9\u4e2a\u6307\u4ee4\u6267\u884c\u540e\uff0c\u670d\u52a1\u5668\u4e0a\u6240\u6709\u7f13\u5b58\u7684\u6570\u636e\u90fd\u88ab\u5220\u9664\uff0c\u5e76\u4e14\u8fd4\u56de\uff1a<BR><FONT color=#0000ff>OK<\/FONT>\\r\\n<\/P><br \/>\n<P>\u8fd9\u4e2a\u6307\u4ee4\u4e00\u822c\u4e0d\u8981\u8f7b\u6613\u4f7f\uff0c\u9664\u975e\u4f60\u5374\u662f\u60f3\u628a\u6240\u6709\u6570\u636e\u90fd\u5e72\u6389\uff0c\u5220\u9664\u5b8c\u4ee5\u540e\u53ef\u4ee5\u65e0\u6cd5\u6062\u590d\u7684\u3002<\/P><br \/>\n<P><BR><FONT size=2><STRONG>[\u5176\u4ed6\u6307\u4ee4]<\/STRONG><\/FONT><BR>\u5982\u679c\u60f3\u4e86\u89e3\u5f53\u524dMemcache\u670d\u52a1\u5668\u7684\u72b6\u6001\u548c\u7248\u672c\u7b49\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528\u72b6\u6001\u67e5\u8be2\u6307\u4ee4\u548c\u7248\u672c\u67e5\u8be2\u6307\u4ee4\u3002<\/P><br \/>\n<P>\u5982\u679c\u60f3\u4e86\u89e3\u5f53\u524d\u6240\u6709Memcache\u670d\u52a1\u5668\u8fd0\u884c\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528stats\u6307\u4ee4\uff0c\u683c\u5f0f<BR><FONT color=#0000ff>stats<\/FONT>\\r\\n<BR>\u670d\u52a1\u5668\u5c06\u8fd4\u56de\u6bcf\u884c\u6309\u7167 STAT \u5f00\u59cb\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u5305\u62ec20\u884c\uff0c20\u9879\u5de6\u53f3\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u5b88\u62a4\u8fdb\u7a0b\u7684pid\u3001\u7248\u672c\u3001\u4fdd\u5b58\u7684\u9879\u76ee\u6570\u91cf\u3001\u5185\u5b58\u5360\u7528\u3001\u6700\u5927\u5185\u5b58\u9650\u5236\u7b49\u7b49\u4fe1\u606f\u3002<BR><BR>\u5982\u679c\u53ea\u662f\u60f3\u83b7\u53d6\u90e8\u5206\u9879\u76ee\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u6307\u5b9a\u53c2\u6570\uff0c\u683c\u5f0f\uff1a<BR><FONT color=#0000ff>stats<\/FONT> &lt;<FONT color=#993300>\u53c2\u6570<\/FONT>&gt;\\r\\n<BR>\u8fd9\u4e2a\u6307\u4ee4\u5c06\u53ea\u8fd4\u56de\u6307\u5b9a\u53c2\u6570\u7684\u9879\u76ee\u72b6\u6001\u4fe1\u606f\u3002<\/P><br \/>\n<P>\u5982\u679c\u53ea\u662f\u60f3\u5355\u72ec\u4e86\u89e3\u5f53\u524d\u7248\u672c\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528version\u6307\u4ee4\uff0c\u683c\u5f0f\uff1a<BR><FONT color=#0000ff>version<\/FONT>\\r\\n<BR>\u5c06\u8fd4\u56de\u4ee5 VERSION \u5f00\u5934\u7684\u7248\u672c\u4fe1\u606f<\/P><br \/>\n<P>\u5982\u679c\u60f3\u7ed3\u675f\u5f53\u524d\u8fde\u63a5\uff0c\u4f7f\u7528quit\u6307\u4ee4\uff0c\u683c\u5f0f\uff1a<BR><FONT color=#0000ff>quit<\/FONT>\\r\\n<\/P><br \/>\n<P>\u5c06\u65ad\u5f00\u5f53\u524d\u8fde\u63a5<\/P><br \/>\n<P>\u53e6\u5916\u8fd8\u6709\u5176\u4ed6\u6307\u4ee4\uff0c\u5305\u62ec<FONT color=#993300>incr<\/FONT>, <FONT color=#993300>decr<\/FONT> \u7b49\uff0c\u6211\u4e5f\u4e0d\u592a\u4e86\u89e3\u4f5c\u7528\uff0c\u5c31\u4e0d\u505a\u4ecb\u7ecd\u4e86\uff0c\u5982\u679c\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u81ea\u5df1\u53bb\u7814\u7a76\u3002<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><FONT size=4><STRONG>\u3010Memcache\u5728\u4e2d\u578b\u7f51\u7ad9\u7684\u4f7f\u7528\u3011<\/STRONG><\/FONT><\/P><br \/>\n<P>\u4f7f\u7528Memcache\u7684\u7f51\u7ad9\u4e00\u822c\u6d41\u91cf\u90fd\u662f\u6bd4\u8f83\u5927\u7684\uff0c\u4e3a\u4e86\u7f13\u89e3\u6570\u636e\u5e93\u7684\u538b\u529b\uff0c\u8ba9Memcache\u4f5c\u4e3a\u4e00\u4e2a\u7f13\u5b58\u533a\u57df\uff0c\u628a\u90e8\u5206\u4fe1\u606f\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u524d\u7aef\u80fd\u591f\u8fc5\u901f\u7684\u8fdb\u884c\u5b58\u53d6\u3002\u90a3\u4e48\u4e00\u822c\u7684\u7126\u70b9\u5c31\u662f\u96c6\u4e2d\u5728\u5982\u4f55\u5206\u62c5\u6570\u636e\u5e93\u538b\u529b\u548c\u8fdb\u884c\u5206\u5e03\u5f0f\uff0c\u6bd5\u7adf\u5355\u53f0Memcache\u7684\u5185\u5b58\u5bb9\u91cf\u7684\u6709\u9650\u7684\u3002\u6211\u8fd9\u91cc\u7b80\u5355\u63d0\u51fa\u6211\u7684\u4e2a\u4eba\u770b\u6cd5\uff0c\u672a\u7ecf\u5b9e\u8df5\uff0c\u6743\u5f53\u53c2\u8003\u3002<\/P><br \/>\n<P><STRONG><FONT size=2>[ \u5206\u5e03\u5f0f\u5e94\u7528]<\/FONT><\/STRONG><BR>Memcache\u672c\u6765\u652f\u6301\u5206\u5e03\u5f0f\uff0c\u6211\u4eec\u5ba2\u6237\u7aef\u7a0d\u52a0\u6539\u9020\uff0c\u66f4\u597d\u7684\u652f\u6301\u3002\u6211\u4eec\u7684key\u53ef\u4ee5\u9002\u5f53\u8fdb\u884c\u6709\u89c4\u5f8b\u7684\u5c01\u88c5\uff0c\u6bd4\u5982\u4ee5user\u4e3a\u4e3b\u7684\u7f51\u7ad9\u6765\u8bf4\uff0c\u6bcf\u4e2a\u7528\u6237\u90fd\u6709User ID\uff0c\u90a3\u4e48\u53ef\u4ee5\u6309\u7167\u56fa\u5b9a\u7684ID\u6765\u8fdb\u884c\u63d0\u53d6\u548c\u5b58\u53d6\uff0c\u6bd4\u59821\u5f00\u5934\u7684\u7528\u6237\u4fdd\u5b58\u5728\u7b2c\u4e00\u53f0Memcache\u670d\u52a1\u5668\u4e0a\uff0c\u4ee52\u5f00\u5934\u7684\u7528\u6237\u7684\u6570\u636e\u4fdd\u5b58\u5728\u7b2c\u4e8c\u80ceMecache\u670d\u52a1\u5668\u4e0a\uff0c\u5b58\u53d6\u6570\u636e\u90fd\u5148\u6309\u7167User ID\u6765\u8fdb\u884c\u76f8\u5e94\u7684\u8f6c\u6362\u548c\u5b58\u53d6\u3002<\/P><br \/>\n<P>\u4f46\u662f\u8fd9\u4e2a\u6709\u7f3a\u70b9\uff0c\u5c31\u662f\u9700\u8981\u5bf9User ID\u8fdb\u884c\u5224\u65ad\uff0c\u5982\u679c\u4e1a\u52a1\u4e0d\u4e00\u81f4\uff0c\u6216\u8005\u5176\u4ed6\u7c7b\u578b\u7684\u5e94\u7528\uff0c\u53ef\u80fd\u4e0d\u662f\u90a3\u4e48\u5408\u9002\uff0c\u90a3\u4e48\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u5b9e\u9645\u4e1a\u52a1\u6765\u8fdb\u884c\u8003\u8651\uff0c\u6216\u8005\u53bb\u60f3\u66f4\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/P><br \/>\n<P><FONT size=2><STRONG>[ \u51cf\u5c11\u6570\u636e\u5e93\u538b\u529b]<\/STRONG><\/FONT><BR>\u8fd9\u4e2a\u7b97\u662f\u6bd4\u8f83\u91cd\u8981\u7684\uff0c\u6240\u6709\u7684\u6570\u636e\u57fa\u672c\u4e0a\u90fd\u662f\u4fdd\u5b58\u5728\u6570\u636e\u5e93\u5f53\u4e2d\u7684\uff0c\u6bcf\u6b21\u9891\u7e41\u7684\u5b58\u53d6\u6570\u636e\u5e93\uff0c\u5bfc\u81f4\u6570\u636e\u5e93\u6027\u80fd\u6781\u5177\u4e0b\u964d\uff0c\u65e0\u6cd5\u540c\u65f6\u670d\u52a1\u66f4\u591a\u7684\u7528\u6237\uff0c\u6bd4\u5982MySQL\uff0c\u7279\u522b\u9891\u7e41\u7684\u9501\u8868\uff0c\u90a3\u4e48\u8ba9Memcache\u6765\u5206\u62c5\u6570\u636e\u5e93\u7684\u538b\u529b\u5427\u3002\u6211\u4eec\u9700\u8981\u4e00\u79cd\u6539\u52a8\u6bd4\u8f83\u5c0f\uff0c\u5e76\u4e14\u80fd\u591f\u4e0d\u4f1a\u5927\u89c4\u6a21\u6539\u53d8\u524d\u7aef\u7684\u65b9\u5f0f\u6765\u8fdb\u884c\u6539\u53d8\u76ee\u524d\u7684\u67b6\u6784\u3002<\/P><br \/>\n<P>\u6211\u8003\u8651\u7684\u4e00\u79cd\u7b80\u5355\u65b9\u6cd5\uff1a<BR>\u540e\u7aef\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u6a21\u5757\uff0c\u628a\u6240\u6709\u7684Select\u64cd\u4f5c\u63d0\u53d6\u51fa\u6765\uff08update\/delete\/insert\u4e0d\u7ba1\uff09\uff0c\u7136\u540e\u628a\u5bf9\u5e94\u7684SQL\u8fdb\u884c\u76f8\u5e94\u7684hash\u7b97\u6cd5\u8ba1\u7b97\u5f97\u51fa\u4e00\u4e2ahash\u6570\u636ekey\uff08\u6bd4\u5982MD5\u6216\u8005SHA\uff09\uff0c\u7136\u540e\u628a\u8fd9\u4e2akey\u53bbMemcache\u4e2d\u67e5\u627e\u6570\u636e\uff0c\u5982\u679c\u8fd9\u4e2a\u6570\u636e\u4e0d\u5b58\u5728\uff0c\u8bf4\u660e\u8fd8\u6ca1\u5199\u5165\u5230\u7f13\u5b58\u4e2d\uff0c\u90a3\u4e48\u4ece\u6570\u636e\u5e93\u628a\u6570\u636e\u63d0\u53d6\u51fa\u6765\uff0c\u4e00\u4e2a\u662f\u6570\u7ec4\u7c7b\u683c\u5f0f\uff0c\u7136\u540e\u628a\u6570\u636e\u5728set\u5230Memcache\u4e2d\uff0ckey\u5c31\u662f\u8fd9\u4e2aSQL\u7684hash\u503c\uff0c\u7136\u540e\u76f8\u5e94\u7684\u8bbe\u7f6e\u4e00\u4e2a\u5931\u6548\u65f6\u95f4\uff0c\u6bd4\u5982\u4e00\u4e2a\u5c0f\u65f6\uff0c\u90a3\u4e48\u4e00\u4e2a\u5c0f\u65f6\u4e2d\u7684\u6570\u636e\u90fd\u662f\u4ece\u7f13\u5b58\u4e2d\u63d0\u53d6\u7684\uff0c\u6709\u6548\u51cf\u5c11\u6570\u636e\u5e93\u7684\u538b\u529b\u3002<\/P><br \/>\n<P>\u7f3a\u70b9\u662f\u6570\u636e\u4e0d\u5b9e\u65f6\uff0c\u5f53\u6570\u636e\u505a\u4e86\u4fee\u6539\u4ee5\u540e\uff0c\u65e0\u6cd5\u5b9e\u65f6\u5230\u524d\u7aef\u663e\u793a\uff0c\u5e76\u4e14\u8fd8\u6709\u53ef\u80fd\u5bf9\u5185\u5b58\u5360\u7528\u6bd4\u8f83\u5927\uff0c\u6bd5\u7adf\u6bcf\u6b21select\u51fa\u6765\u7684\u6570\u636e\u6570\u91cf\u53ef\u80fd\u6bd4\u8f83\u5de8\u5927\uff0c\u8fd9\u4e2a\u662f\u9700\u8981\u8003\u8651\u7684\u56e0\u7d20\u3002<\/P><br \/>\n<P>\u4e0a\u9762\u53ea\u662f\u6211\u4e24\u70b9\u6ca1\u6709\u7ecf\u8fc7\u6df1\u601d\u719f\u8651\u7684\u7b80\u5355\u60f3\u6cd5\uff0c\u4e5f\u8bb8\u6709\u7528\uff0c\u90a3\u5c31\u6700\u597d\u4e86\u3002<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><FONT size=4><STRONG>\u3010Memcache\u7684\u5b89\u5168\u3011<\/STRONG><\/FONT><\/P><br \/>\n<P>\u6211\u4eec\u4e0a\u9762\u7684Memcache\u670d\u52a1\u5668\u7aef\u90fd\u662f\u76f4\u63a5\u901a\u8fc7\u5ba2\u6237\u7aef\u8fde\u63a5\u540e\u76f4\u63a5\u64cd\u4f5c\uff0c\u6ca1\u6709\u4efb\u4f55\u7684\u9a8c\u8bc1\u8fc7\u7a0b\uff0c\u8fd9\u6837\u5982\u679c\u670d\u52a1\u5668\u662f\u76f4\u63a5\u66b4\u9732\u5728\u4e92\u8054\u7f51\u4e0a\u7684\u8bdd\u662f\u6bd4\u8f83\u5371\u9669\uff0c\u8f7b\u5219\u6570\u636e\u6cc4\u9732\u88ab\u5176\u4ed6\u65e0\u5173\u4eba\u5458\u67e5\u770b\uff0c\u91cd\u5219\u670d\u52a1\u5668\u88ab\u5165\u4fb5\uff0c\u56e0\u4e3aMecache\u662f\u4ee5root\u6743\u9650\u8fd0\u884c\u7684\uff0c\u51b5\u4e14\u91cc\u9762\u53ef\u80fd\u5b58\u5728\u4e00\u4e9b\u6211\u4eec\u672a\u77e5\u7684bug\u6216\u8005\u662f\u7f13\u51b2\u533a\u6ea2\u51fa\u7684\u60c5\u51b5\uff0c\u8fd9\u4e9b\u90fd\u662f\u6211\u4eec\u672a\u77e5\u7684\uff0c\u6240\u4ee5\u5371\u9669\u6027\u662f\u53ef\u4ee5\u9884\u89c1\u7684\u3002<\/P><br \/>\n<P>\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u6211\u505a\u4e24\u70b9\u5efa\u8bae\uff0c\u80fd\u591f\u7a0d\u5fae\u7684\u9632\u6b62\u9ed1\u5ba2\u7684\u5165\u4fb5\u6216\u8005\u6570\u636e\u7684\u6cc4\u9732\u3002<\/P><br \/>\n<P><FONT size=2><STRONG>[ \u5185\u7f51\u8bbf\u95ee]<\/STRONG><\/FONT><BR>\u6700\u597d\u628a\u4e24\u53f0\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8bbf\u95ee\u662f\u5185\u7f51\u5f62\u6001\u7684\uff0c\u4e00\u822c\u662fWeb\u670d\u52a1\u5668\u8ddfMemcache\u670d\u52a1\u5668\u4e4b\u95f4\u3002\u666e\u904d\u7684\u670d\u52a1\u5668\u90fd\u662f\u6709\u4e24\u5757\u7f51\u5361\uff0c\u4e00\u5757\u6307\u5411\u4e92\u8054\u7f51\uff0c\u4e00\u5757\u6307\u5411\u5185\u7f51\uff0c\u90a3\u4e48\u5c31\u8ba9Web\u670d\u52a1\u5668\u901a\u8fc7\u5185\u7f51\u7684\u7f51\u5361\u6765\u8bbf\u95eeMemcache\u670d\u52a1\u5668\uff0c\u6211\u4eecMemcache\u7684\u670d\u52a1\u5668\u4e0a\u542f\u52a8\u7684\u65f6\u5019\u5c31\u76d1\u542c\u5185\u7f51\u7684IP\u5730\u5740\u548c\u7aef\u53e3\uff0c\u5185\u7f51\u95f4\u7684\u8bbf\u95ee\u80fd\u591f\u6709\u6548\u963b\u6b62\u5176\u4ed6\u975e\u6cd5\u7684\u8bbf\u95ee\u3002<\/P><br \/>\n<P><FONT color=#0000ff># memcached -d -m 1024&nbsp; -u root -l 192.168.0.200 -p 11211 -c 1024 -P \/tmp\/memcached.pid<\/FONT><\/P><br \/>\n<P>Memcache\u670d\u52a1\u5668\u7aef\u8bbe\u7f6e\u76d1\u542c\u901a\u8fc7\u5185\u7f51\u7684192.168.0.200\u7684ip\u768411211\u7aef\u53e3\uff0c\u5360\u75281024MB\u5185\u5b58\uff0c\u5e76\u4e14\u5141\u8bb8\u6700\u59271024\u4e2a\u5e76\u53d1\u8fde\u63a5<\/P><br \/>\n<P><BR><FONT size=2><STRONG>[ \u8bbe\u7f6e\u9632\u706b\u5899]<\/STRONG><\/FONT><BR>\u9632\u706b\u5899\u662f\u7b80\u5355\u6709\u6548\u7684\u65b9\u5f0f\uff0c\u5982\u679c\u5374\u662f\u4e24\u53f0\u670d\u52a1\u5668\u90fd\u662f\u6302\u5728\u7f51\u7684\uff0c\u5e76\u4e14\u9700\u8981\u901a\u8fc7\u5916\u7f51IP\u6765\u8bbf\u95eeMemcache\u7684\u8bdd\uff0c\u90a3\u4e48\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u9632\u706b\u5899\u6216\u8005\u4ee3\u7406\u7a0b\u5e8f\u6765\u8fc7\u6ee4\u975e\u6cd5\u8bbf\u95ee\u3002<BR>\u4e00\u822c\u6211\u4eec\u5728Linux\u4e0b\u53ef\u4ee5\u4f7f\u7528iptables\u6216\u8005FreeBSD\u4e0b\u7684ipfw\u6765\u6307\u5b9a\u4e00\u4e9b\u89c4\u5219\u9632\u6b62\u4e00\u4e9b\u975e\u6cd5\u7684\u8bbf\u95ee\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u53ea\u5141\u8bb8\u6211\u4eec\u7684Web\u670d\u52a1\u5668\u6765\u8bbf\u95ee\u6211\u4eecMemcache\u670d\u52a1\u5668\uff0c\u540c\u65f6\u963b\u6b62\u5176\u4ed6\u7684\u8bbf\u95ee\u3002<\/P><br \/>\n<P><FONT color=#0000ff># iptables -F<BR># iptables -P INPUT DROP<BR># iptables -A INPUT -p tcp -s 192.168.0.2 &#8211;dport 11211 -j ACCEPT<BR># iptables -A INPUT -p udp -s 192.168.0.2 &#8211;dport 11211 -j ACCEPT<\/FONT><\/P><br \/>\n<P>\u4e0a\u9762\u7684iptables\u89c4\u5219\u5c31\u662f\u53ea\u5141\u8bb8192.168.0.2\u8fd9\u53f0Web\u670d\u52a1\u5668\u5bf9Memcache\u670d\u52a1\u5668\u7684\u8bbf\u95ee\uff0c\u80fd\u591f\u6709\u6548\u7684\u963b\u6b62\u4e00\u4e9b\u975e\u6cd5\u8bbf\u95ee\uff0c\u76f8\u5e94\u7684\u4e5f\u53ef\u4ee5\u589e\u52a0\u4e00\u4e9b\u5176\u4ed6\u7684\u89c4\u5219\u6765\u52a0\u5f3a\u5b89\u5168\u6027\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u6765\u505a\u3002<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><FONT size=4><STRONG>\u3010Memcache\u7684\u6269\u5c55\u6027\u3011<\/STRONG><\/FONT><\/P><br \/>\n<P>Memcache\u7b97\u662f\u6bd4\u8f83\u7b80\u6d01\u9ad8\u6548\u7684\u7a0b\u5e8f\uff0cMemcache 1.2.0 \u7684\u6e90\u4ee3\u7801\u5927\u5c0f\u624d139K\uff0c\u5728Windows\u5e73\u53f0\u4e0a\u662f\u4e0d\u53ef\u60f3\u8c61\u7684\uff0c\u4f46\u662f\u5728\u5f00\u6e90\u4e16\u754c\u6765\u8bf4\uff0c\u8fd9\u662f\u6bd4\u8f83\u6b63\u5e38\u5408\u7406\u7684\u3002<BR>Memcache\u76ee\u524d\u90fd\u53ea\u662f\u6bd4\u8f83\u7b80\u5355\u7684\u529f\u80fd\uff0c\u7b80\u5355\u7684\u6570\u636e\u5b58\u53d6\u529f\u80fd\uff0c\u6211\u4e2a\u4eba\u5e0c\u671b\u5982\u679c\u6709\u8bc6\u4e4b\u58eb\uff0c\u80fd\u591f\u5728\u4e0b\u9762\u4e24\u65b9\u9762\u8fdb\u884c\u6269\u5c55\u3002<\/P><br \/>\n<P><STRONG><FONT size=2>1. \u65e5\u5fd7\u529f\u80fd<\/FONT><\/STRONG><BR>\u76ee\u524dMemcache\u6ca1\u6709\u65e5\u5fd7\u529f\u80fd\uff0c\u53ea\u6709\u4e00\u4e9b\u547d\u4ee4\u5728\u670d\u52a1\u5668\u7aef\u8fdb\u884c\u56de\u663e\uff0c\u8fd9\u6837\u662f\u5f88\u4e0d\u5229\u4e8e\u5bf9\u4e00\u4e2a\u670d\u52a1\u5668\u7684\u7a33\u5b9a\u6027\u548c\u8d1f\u8f7d\u7b49\u7b49\u8fdb\u884c\u76d1\u63a7\u7684\uff0c\u6700\u597d\u80fd\u591f\u76f8\u5e94\u7684\u52a0\u4e0a\u65e5\u5fd7\u7684\u7b49\u529f\u80fd\uff0c\u4fbf\u4e8e\u76d1\u63a7\u3002<\/P><br \/>\n<P><STRONG><FONT size=2>2. \u5b58\u50a8\u7ed3\u6784<\/FONT><\/STRONG><BR>\u76ee\u524d\u7684\u6570\u636e\u5f62\u5f0f\u5c31\u662f: key =&gt; data \u7684\u5f62\u5f0f\uff0c\u7279\u522b\u5355\u4e00\uff0c\u53ea\u80fd\u591f\u5b58\u50a8\u5355\u4e00\u7684\u4e00\u7ef4\u6570\u636e\uff0c\u5982\u679c\u80fd\u591f\u6269\u5c55\u7684\u8bdd\uff0c\u53d8\u6210\u7c7b\u4f3c\u6570\u636e\u5e93\u7684\u683c\u5f0f\uff0c\u80fd\u591f\u5b58\u50a8\u4e8c\u7ef4\u6570\u636e\uff0c\u90a3\u6837\u4f1a\u8ba9\u53ef\u4ee5\u7528\u6027\u66f4\u5f3a\uff0c\u4f7f\u7528\u9762\u66f4\u5e7f\uff0c\u5f53\u7136\u76f8\u5e94\u7684\u53ef\u80fd\u4ee3\u7801\u6548\u7387\u548c\u5b58\u53d6\u6548\u7387\u66f4\u5dee\u4e00\u4e9b\u3002<\/P><br \/>\n<P><STRONG><FONT size=2>3. \u540c\u6b65\u529f\u80fd<\/FONT><\/STRONG><BR>\u6570\u636e\u540c\u6b65\u662f\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u6280\u672f\uff0c\u56e0\u4e3a\u8c01\u90fd\u4e0d\u80fd\u4fdd\u8bc1\u4e00\u53f0\u670d\u52a1\u5668\u662f\u6301\u4e45\u6b63\u5e38\u7684\u8fd0\u884c\u7684\uff0c\u5982\u679c\u80fd\u591f\u5177\u6709\u7c7b\u4f3cMySQL\u7684 Master\/Slave \u7684\u529f\u80fd\uff0c\u90a3\u4e48\u5c06\u4f7f\u5f97Memcache\u7684\u6570\u636e\u66f4\u52a0\u7a33\u5b9a\uff0c\u90a3\u4e48\u76f8\u5e94\u7684\u5c31\u53ef\u4ee5\u8003\u8651\u5b58\u50a8\u6301\u4e45\u4e00\u70b9\u7684\u6570\u636e\uff0c\u5e76\u4e14\u4e0d\u7528\u5bb3\u6015Memcache\u7684down\u6389\uff0c\u56e0\u4e3a\u6709\u540c\u6b65\u7684\u5907\u4efd\u670d\u52a1\u5668\uff0c\u8fd9\u4e2a\u95ee\u9898\u5c31\u4e0d\u662f\u95ee\u9898\u4e86\u3002<\/P><br \/>\n<P>\u4ee5\u4e0a\u4e09\u70b9\u53ea\u662f\u4e2a\u4eba\u62d9\u89c1\uff0c\u6709\u8bc6\u4e4b\u58eb\u548c\u6280\u672f\u9ad8\u624b\u53ef\u4ee5\u8003\u8651\u3002<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><FONT size=4><STRONG>\u3010\u7ed3\u675f\u8bed\u3011<\/STRONG><\/FONT><\/P><br \/>\n<P>\u6211\u4e0a\u9762\u7684\u5185\u5bb9\u90fd\u53ea\u662f\u81ea\u5df1\u5b89\u88c5\u548c\u4f7f\u7528\u7684\u4e00\u4e9b\u60f3\u6cd5\uff0c\u4e0d\u80fd\u4fdd\u8bc1\u7edd\u5bf9\u6b63\u786e\uff0c\u53ea\u662f\u7ed9\u9700\u8981\u7684\u4eba\u4e00\u4e2a\u53c2\u8003\uff0c\u4e00\u4e2a\u63a8\u5e7fMemcache\u7684\u6587\u7ae0\uff0c\u5e0c\u671b\u66f4\u591a\u7684\u4eba\u80fd\u591f\u8ba4\u8bc6\u548c\u4e86\u89e3\u8fd9\u4e2a\u6280\u672f\uff0c\u5e76\u4e14\u4e3a\u81ea\u5df1\u6240\u7528\u3002<\/P><br \/>\n<P>\u6211\u82b1\u8d39\u4e86\u6574\u6574\u4e00\u4e2a\u665a\u4e0a\u7684\u65f6\u95f4\u6d0b\u6d0b\u6d12\u6d12\u7684\u5199\u4e86\u8fd9\u4e48\u957f\uff0c\u65e0\u975e\u662f\u5bf9\u4e8e\u8fd9\u9879\u5f00\u6e90\u6280\u672f\u7684\u70ed\u7231\uff0c\u6211\u60f3\u5f00\u6e90\u4e16\u754c\u80fd\u591f\u7e41\u8363\u8d77\u6765\uff0c\u5c31\u662f\u6e90\u4e8e\u5927\u5bb6\u7684\u70ed\u7231\u5e76\u4e14\u613f\u610f\u505a\u51fa\u8d21\u732e\uff0c\u5f00\u6e90\u4e16\u754c\u624d\u8fd9\u4e48\u7cbe\u5f69\u3002<\/P><br \/>\n<P>\u5e0c\u671b\u672c\u6587\u80fd\u591f\u7ed9\u9700\u8981\u7684\u4eba\u4e00\u4e9b\u5e2e\u52a9\uff0c\u5e0c\u671b\u4e0d\u4f1a\u8bef\u5bfc\u4ed6\u4eec\uff0c\u5475\u5475\u3002<\/P><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Memcache\u7684\u4f7f\u7528\u548c\u534f\u8bae\u5206\u6790\u8be6\u89e3 \u4f5c\u8005\uff1aheiyeluren\u535a\u5ba2\uff1ahttp:\/\/blog.csdn.net\/heiyeshuwu\u65f6\u95f4\uff1a2006-11-12\u5173\u952e\u5b57\uff1aPHP Memcache Linux \u7f13\u5b58 Memcache\u662fdanga.com\u7684\u4e00\u4e2a\u9879\u76ee\uff0c\u6700\u65e9\u662f\u4e3a LiveJournal \u670d\u52a1\u7684\uff0c\u76ee\u524d\u5168\u4e16\u754c\u4e0d\u5c11\u4eba\u4f7f\u7528\u8fd9\u4e2a\u7f13\u5b58\u9879\u76ee\u6765\u6784\u5efa\u81ea\u5df1\u5927\u8d1f\u8f7d\u7684\u7f51\u7ad9\uff0c\u6765\u5206\u62c5\u6570\u636e\u5e93\u7684\u538b\u529b\u3002\uff08\u5173\u4e8eMemcache\u7684\u66f4\u591a\u4fe1\u606f\u8bf7Google\uff09Memcache\u5b98\u65b9\u7f51\u7ad9\uff1ahttp:\/\/www.danga.com\/memcached \u3010\u5b89\u88c5Memcache\u670d\u52a1\u5668\u7aef\u3011 \u6211\u76ee\u524d\u7684\u5e73\u53f0\uff0c\u670d\u52a1\u5668\u662fFedora Core 1\uff08\u5185\u6838\uff1a2.4.22\uff09\uff0c\u5ba2\u6237\u7aef\u662fWindows XP SP2\uff0c\u9700\u8981\u5b89\u88c5\u7684\u5c31\u662f\u670d\u52a1\u5668\u7684Memcached\u7684\u5b88\u62a4\u8fdb\u7a0b\u548c\u5ba2\u6237\u7aef\u7684PHP\u6269\u5c55php_memcache\u4e24\u4e2a\u4e1c\u897f\u3002\u73b0\u5728\u6211\u5206\u522b\u6765\u8bb2\u3002 \u670d\u52a1\u5668\u7aef\u4e3b\u8981\u662f\u5b89\u88c5memcache\u670d\u52a1\u5668\u7aef\uff0c\u76ee\u524d\u7684\u6700\u65b0\u7248\u672c\u662f memcached-1.2.0 \u3002\u4e0b\u8f7d\uff1ahttp:\/\/www.danga.com\/memcached\/dist\/memcached-1.2.0.tar.gz\u53e6\u5916\uff0cMemcache\u7528\u5230\u4e86libevent\u8fd9\u4e2a\u5e93\u7528\u4e8eSocket\u7684\u5904\u7406\uff0c\u6240\u4ee5\u8fd8\u9700\u8981\u5b89\u88c5libevent\uff0clibevent\u7684\u6700\u65b0\u7248\u672c\u662flibevent-1.2\u3002\uff08\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86libevent\uff0c\u53ef\u4ee5\u4e0d\u7528\u5b89\u88c5\uff09\u5b98\u7f51\uff1ahttp:\/\/www.monkey.org\/~provos\/libevent\/\u4e0b\u8f7d\uff1ahttp:\/\/www.monkey.org\/~provos\/libevent-1.2.tar.gz \u6211\u5206\u522b\u628a\u4e24\u4e2a\u4e1c\u4e1c\u4e0b\u8f7d\u56de\u6765\uff0c\u653e\u5230 \/tmp \u76ee\u5f55\u4e0b\uff1a# cd \/tmp# wget http:\/\/www.danga.com\/memcached\/dist\/memcached-1.2.0.tar.gz# wget http:\/\/www.monkey.org\/~provos\/libevent-1.2.tar.gz \u5148\u5b89\u88c5libevent\uff1a# tar zxvf libevent-1.2.tar.gz# cd libevent-1.2# .\/configure &#8211;prefix=\/usr# make# make install \u7136\u540e\u770b\u770b\u6211\u4eec\u7684libevent\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a# ls -al \/usr\/lib | grep libeventlrwxrwxrwx&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;21 11?? 12 17:38 libevent-1.2.so.1 -&gt; libevent-1.2.so.1.0.3-rwxr-xr-x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; &hellip; <a href=\"https:\/\/www.strongd.net\/?p=534\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Memcache\u7684\u4f7f\u7528\u548c\u534f\u8bae\u5206\u6790\u8be6\u89e3(php)<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,35,20],"tags":[34],"class_list":["post-534","post","type-post","status-publish","format-standard","hentry","category-linux","category-35","category-20","tag-memcached"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=534"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/534\/revisions"}],"predecessor-version":[{"id":834,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/534\/revisions\/834"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}