{"id":149,"date":"2011-12-05T17:31:28","date_gmt":"2011-12-05T17:31:28","guid":{"rendered":"https:\/\/shan.info\/new\/memcached-%e9%85%8d%e7%bd%ae-config\/"},"modified":"2011-12-05T17:31:28","modified_gmt":"2011-12-05T17:31:28","slug":"memcached-%e9%85%8d%e7%bd%ae-config","status":"publish","type":"post","link":"https:\/\/shan.info\/new\/memcached-%e9%85%8d%e7%bd%ae-config\/","title":{"rendered":"memcached \u914d\u7f6e config"},"content":{"rendered":"<p>\u542f\u52a8<span style=\"background-color: #99d9ea;\">memcached<\/span><br \/> <span style=\"background-color: #99d9ea;\"><span style=\"background-color: #ffffff;\">#<\/span> service<\/span> <span style=\"background-color: #99d9ea;\">memcached<\/span><span style=\"background-color: #99d9ea;\">start<\/span><\/p>\n<p><!--more--><\/p>\n<p>\u542f\u52a8<span style=\"background-color: #99d9ea;\">memcached<\/span><br \/> <span style=\"background-color: #99d9ea;\"><span style=\"background-color: #ffffff;\">#<\/span> service<\/span> <span style=\"background-color: #99d9ea;\">memcached<\/span><span style=\"background-color: #99d9ea;\">start<\/span><\/p>\n<p> \u8bbe\u7f6e<span style=\"background-color: #99d9ea;\">memcached<\/span>\u81ea\u52a8\u542f\u52a8<br \/> # <span style=\"background-color: #99d9ea;\">chkconfig<\/span> <span style=\"background-color: #99d9ea;\">memcached<\/span> <span style=\"background-color: #99d9ea;\">on<\/span><br \/> memcached \u914d\u7f6e\u6587\u4ef6<\/p>\n<p>memcached \u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u00a0<\/p>\n<p>#memcached \u76d1\u542c\u7aef\u53e3\u53f7<\/p>\n<p>PORT=&#8221;11211&#8243;<\/p>\n<p>#memcached\u542f\u52a8\u7528\u6237<\/p>\n<p>USER=&#8221;nobody&#8221;<br \/> # \u6700\u5927\u5e76\u53d1\u94fe\u63a5\u6570<br \/> MAXCONN=&#8221;2048&#8243;<br \/> # memcached \u542f\u52a8\u540e\u5206\u914d\u5185\u5b58\u5927\u5c0f<br \/> CACHESIZE=&#8221;4096&#8243;<br \/> # memcached\u542f\u52a8\u7684\u5176\u5b83\u53c2\u6570, memcached \u76d1\u542c\u7684ip\u5730\u5740,\u53ea\u76d1\u542c\u672c\u673a\u4f7f\u7528127.0.0.1<br \/> OPTIONS=&#8221;-l 127.0.0.1&#8243;<\/p>\n<p>\u5b89\u88c5php\u7684memcached\u6269\u5c55\u5305<\/p>\n<p># yum install php-pecl-memcache<\/p>\n<p>\u4f7f\u7528\u4e0b\u9762\u6d4b\u8bd5\u4f8b\u5b50\u6d4b\u8bd5<\/p>\n<p><code><!--?php<br \/--> $memcache = new Memcache;<br \/> $memcache-&gt;connect('localhost', 11211) or die (\"Could not connect\");<\/p>\n<p> $version = $memcache-&gt;getVersion();<br \/> echo \"Server's version: \".$version.\"<br \/> n\";<\/p>\n<p> $tmp_object = new stdClass;<br \/> $tmp_object-&gt;str_attr = 'test';<br \/> $tmp_object-&gt;int_attr = 123;<\/p>\n<p> $memcache-&gt;set('key', $tmp_object, false, 10) or die (\"Failed to save data at the server\");<br \/> echo \"Store data in the cache (data will expire in 10 seconds)<br \/> n\";<\/p>\n<p> $get_result = $memcache-&gt;get('key');<br \/> echo \"Data from the cache:<br \/> n\";<\/p>\n<p> var_dump($get_result);<\/p>\n<p> ?&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u52a8memcached # service memcachedstart<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-149","post","type-post","status-publish","format-standard","hentry","category-centos-6"],"_links":{"self":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":0,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"wp:attachment":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}