{"id":5790,"date":"2013-11-07T09:41:55","date_gmt":"2013-11-07T01:41:55","guid":{"rendered":"http:\/\/jpuyy.com\/?p=5790"},"modified":"2014-01-08T10:37:56","modified_gmt":"2014-01-08T02:37:56","slug":"command-line-use-memcached","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=5790","title":{"rendered":"\u547d\u4ee4\u884c\u8bbf\u95eememcached"},"content":{"rendered":"<p>\u6709\u5f88\u591a\u7684web\u7aef\u548cGUI\u53ef\u4ee5\u8bbf\u95ee\u5230Memcached\u670d\u52a1\uff0c\u6bd4\u5982phpMemCacheAdmin\uff0c\u4f46\u662f\u6709\u4e9b\u65f6\u5019\u9700\u8981\u5728\u547d\u4ee4\u884c\u8fdb\u884cMemcached\u7684\u8bbf\u95ee\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\u4f7f\u7528Telnet\u6765\u653b\u53d6Memcached\u4fe1\u606f\uff0c\u4ee5\u53ca\u5982\u4f55\u8bfb\u53d6\u4e0e\u5220\u9664\u6570\u636e\u3002 \u8fde\u63a5<\/p>\n<pre>telnet localhost 11211<\/pre>\n<p>\u83b7\u53d6\u670d\u52a1\u4fe1\u606f\uff0c\u5982pid, uptime, version, \u6761\u76ee\u6570, \u8fde\u63a5\u6570<\/p>\n<pre>stats<\/pre>\n<p>\u83b7\u53d6slab\u4fe1\u606f\uff0c\u90a3\u4e48\u4ec0\u4e48\u662fslab Memory is allocated in chunks internally and constantly reused. Since memory is broken into different size slabs, you do waste memory if your items do not fit perfectly into the slab the server chooses to put it in. Memcached\u4f1a\u6839\u636e\u4f60\u6570\u636e\u7684\u5927\u5c0f\u6765\u5b58\u653e\u4e0d\u540c\u7684slab\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u7247\u6216\u5206\u533a\uff0c\u8fd9\u6837\u4e0d\u4f1a\u6d6a\u8d39\u5185\u5b58\u3002<\/p>\n<pre>stats slabs<\/pre>\n<p>\u83b7\u53d6\u6761\u76ee\u4fe1\u606f<\/p>\n<pre>stats items<\/pre>\n<p>\u8bbf\u95ee\u548c\u5220\u9664\u6570\u636e<\/p>\n<p>\u77e5\u9053slab\u7684\u6982\u5ff5\u548c\u4fe1\u606f\u4e4b\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u8bbf\u95eeslab<\/p>\n<pre>stats cachedump [slab ID] [number of items, 0 for all items]<\/pre>\n<p>\u5982\u5728ID=36\u7684slab\u4e2d\u67093\u4e2a\u6761\u76ee<\/p>\n<pre>stats cachedump 36 0\r\nITEM model1 [223301 b; 1383751902 s]\r\nITEM modelNodeid1 [223301 b; 1383751902 s]\r\nITEM id1 [223300 b; 1383751902 s]\r\nEND<\/pre>\n<p>\u83b7\u53d6id1<\/p>\n<pre>get id1<\/pre>\n<p>\u5220\u9664id1<\/p>\n<pre>delete id1<\/pre>\n<p>\u9000\u51fa<\/p>\n<pre>quit \u6216 ctrl + ]<\/pre>\n<p>Command Description Example<\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<td>get<\/td>\n<td>Reads a value<\/td>\n<td>get mykey<\/td>\n<\/tr>\n<tr>\n<td>set<\/td>\n<td>Set a key unconditionally<\/td>\n<td>set mykey 0 60 5<\/td>\n<\/tr>\n<tr>\n<td>add<\/td>\n<td>Add a new key<\/td>\n<td>add newkey 0 60 5<\/td>\n<\/tr>\n<tr>\n<td>replace<\/td>\n<td>Overwrite existing key<\/td>\n<td>replace key 0 60 5<\/td>\n<\/tr>\n<tr>\n<td>append<\/td>\n<td>Append data to existing key<\/td>\n<td>append key 0 60 15<\/td>\n<\/tr>\n<tr>\n<td>prepend<\/td>\n<td>Prepend data to existing key<\/td>\n<td>prepend key 0 60 15<\/td>\n<\/tr>\n<tr>\n<td>incr<\/td>\n<td>Increments numerical key value by given number<\/td>\n<td>incr mykey 2<\/td>\n<\/tr>\n<tr>\n<td>decr<\/td>\n<td>Decrements numerical key value by given number<\/td>\n<td>decr mykey 5<\/td>\n<\/tr>\n<tr>\n<td>delete<\/td>\n<td>Deletes an existing key<\/td>\n<td>delete mykey<\/td>\n<\/tr>\n<tr>\n<td>flush_all<\/td>\n<td>Invalidate specific items immediately<\/td>\n<td>flush_all<\/td>\n<\/tr>\n<tr>\n<td>Invalidate all items in n seconds<\/td>\n<td>flush_all 900<\/td>\n<\/tr>\n<tr>\n<td>stats<\/td>\n<td>Prints general statistics<\/td>\n<td>stats<\/td>\n<\/tr>\n<tr>\n<td>Prints memory statistics<\/td>\n<td>stats slabs<\/td>\n<\/tr>\n<tr>\n<td>Prints memory statistics<\/td>\n<td>stats malloc<\/td>\n<\/tr>\n<tr>\n<td>Print higher level allocation statistics<\/td>\n<td>stats items<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>stats detail<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>stats sizes<\/td>\n<\/tr>\n<tr>\n<td>Resets statistics<\/td>\n<td>stats reset<\/td>\n<\/tr>\n<tr>\n<td>version<\/td>\n<td>Prints server version.<\/td>\n<td>version<\/td>\n<\/tr>\n<tr>\n<td>verbosity<\/td>\n<td>Increases log level<\/td>\n<td>verbosity<\/td>\n<\/tr>\n<tr>\n<td>quit<\/td>\n<td>Terminate telnet session<\/td>\n<td>quit<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53c2\u8003\uff1a http:\/\/www.alphadevx.com\/a\/90-Accessing-Memcached-from-the-command-line<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u5f88\u591a\u7684web\u7aef\u548cGUI\u53ef\u4ee5\u8bbf\u95ee\u5230Memcached\u670d\u52a1\uff0c\u6bd4\u5982phpMemCacheAdmin\uff0c\u4f46\u662f\u6709\u4e9b\u65f6\u5019\u9700\u8981\u5728\u547d\u4ee4\u884c\u8fdb\u884cMemcached\u7684\u8bbf\u95ee\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\u4f7f\u7528Telnet\u6765\u653b\u53d6Memcached\u4fe1\u606f\uff0c\u4ee5\u53ca\u5982\u4f55\u8bfb\u53d6\u4e0e\u5220\u9664\u6570\u636e\u3002 \u8fde\u63a5 telnet localhost 11211 \u83b7\u53d6\u670d\u52a1\u4fe1\u606f\uff0c\u5982pid, uptime, version, \u6761\u76ee\u6570, \u8fde\u63a5\u6570 stats \u83b7\u53d6slab\u4fe1\u606f\uff0c\u90a3\u4e48\u4ec0\u4e48\u662fslab Memory is allocated in chunks internally and constantly reused. Since memory is broken into different size slabs, you do waste memory if your items do not fit perfectly into the slab the server chooses to put it in. Memcached\u4f1a\u6839\u636e\u4f60\u6570\u636e\u7684\u5927\u5c0f\u6765\u5b58\u653e\u4e0d\u540c\u7684slab\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u7247\u6216\u5206\u533a\uff0c\u8fd9\u6837\u4e0d\u4f1a\u6d6a\u8d39\u5185\u5b58\u3002 stats slabs \u83b7\u53d6\u6761\u76ee\u4fe1\u606f [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-5790","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5790"}],"version-history":[{"count":7,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5790\/revisions"}],"predecessor-version":[{"id":6078,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5790\/revisions\/6078"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}