{"id":166757,"date":"2024-11-05T19:14:21","date_gmt":"2024-11-05T11:14:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/166757\/"},"modified":"2024-11-05T19:14:21","modified_gmt":"2024-11-05T11:14:21","slug":"%e4%be%86%e6%8f%90%e5%8d%87%e7%a8%8b%e5%ba%8f%e6%80%a7%e8%83%bd%e5%88%a9%e7%94%a8redis%e7%9a%84%e5%91%bd%e4%bb%a4%e6%8f%90%e5%8d%87%e7%a8%8b%e5%ba%8f%e6%80%a7%e8%83%bd%ef%bc%88redis-%e7%8d%b2%e5%8f%96","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/166757\/","title":{"rendered":"\u4f86\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\u5229\u7528Redis\u7684\u547d\u4ee4\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\uff08redis \u7372\u53d6\u6578\u64da\u547d\u4ee4\uff09"},"content":{"rendered":"<h1 id=\"%e4%be%86%e6%8f%90%e5%8d%87%e7%a8%8b%e5%ba%8f%e6%80%a7%e8%83%bd%e5%88%a9%e7%94%a8redis%e7%9a%84%e5%91%bd%e4%bb%a4%e6%8f%90%e5%8d%87%e7%a8%8b%e5%ba%8f%e6%80%a7%e8%83%bd%ef%bc%88redis-%e7%8d%b2%e5%8f%96-ryJbRHRlbS\">\u4f86\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\u5229\u7528Redis\u7684\u547d\u4ee4\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\uff08redis \u7372\u53d6\u6578\u64da\u547d\u4ee4\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u61c9\u7528\u4e2d\uff0c\u6027\u80fd\u662f\u5f71\u97ff\u7528\u6236\u9ad4\u9a57\u7684\u95dc\u9375\u56e0\u7d20\u4e4b\u4e00\u3002\u96a8\u8457\u6578\u64da\u91cf\u7684\u589e\u9577\uff0c\u5982\u4f55\u9ad8\u6548\u5730\u5b58\u53d6\u548c\u7ba1\u7406\u6578\u64da\u6210\u70ba\u4e86\u958b\u767c\u8005\u9762\u81e8\u7684\u4e00\u5927\u6311\u6230\u3002Redis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u5167\u5b58\u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u547d\u4ee4\u4f86\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\uff0c\u7279\u5225\u662f\u5728\u6578\u64da\u7372\u53d6\u65b9\u9762\u3002\u672c\u6587\u5c07\u63a2\u8a0eRedis\u7684\u57fa\u672c\u547d\u4ee4\u53ca\u5176\u5728\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\u4e2d\u7684\u61c9\u7528\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afredis%ef%bc%9f-ryJbRHRlbS\">\u4ec0\u9ebc\u662fRedis\uff1f<\/h2>\n<p>Redis\uff08Remote Dictionary Server\uff09\u662f\u4e00\u500b\u958b\u6e90\u7684\u9ad8\u6027\u80fd\u9375\u503c\u6578\u64da\u5eab\uff0c\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u5982\u5b57\u7b26\u4e32\u3001\u54c8\u5e0c\u3001\u5217\u8868\u3001\u96c6\u5408\u548c\u6709\u5e8f\u96c6\u5408\u7b49\u3002\u7531\u65bc\u5176\u9ad8\u6548\u7684\u5167\u5b58\u5b58\u53d6\u7279\u6027\uff0cRedis\u88ab\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u5be6\u6642\u6578\u64da\u5206\u6790\u7b49\u5834\u666f\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e5%9f%ba%e6%9c%ac%e5%91%bd%e4%bb%a4-ryJbRHRlbS\">Redis\u7684\u57fa\u672c\u547d\u4ee4<\/h2>\n<p>Redis\u63d0\u4f9b\u4e86\u591a\u7a2e\u547d\u4ee4\u4f86\u64cd\u4f5c\u6578\u64da\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u7372\u53d6\u6578\u64da\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li><code>GET<\/code>\uff1a\u7528\u65bc\u7372\u53d6\u6307\u5b9a\u9375\u7684\u503c\u3002<\/li>\n<li><code>MGET<\/code>\uff1a\u7528\u65bc\u4e00\u6b21\u7372\u53d6\u591a\u500b\u9375\u7684\u503c\u3002<\/li>\n<li><code>HGET<\/code>\uff1a\u7528\u65bc\u7372\u53d6\u54c8\u5e0c\u8868\u4e2d\u6307\u5b9a\u5b57\u6bb5\u7684\u503c\u3002<\/li>\n<li><code>LRANGE<\/code>\uff1a\u7528\u65bc\u7372\u53d6\u5217\u8868\u4e2d\u6307\u5b9a\u7bc4\u570d\u7684\u5143\u7d20\u3002<\/li>\n<li><code>ZRANGE<\/code>\uff1a\u7528\u65bc\u7372\u53d6\u6709\u5e8f\u96c6\u5408\u4e2d\u6307\u5b9a\u7bc4\u570d\u7684\u5143\u7d20\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8redis%e5%91%bd%e4%bb%a4%e6%8f%90%e5%8d%87%e7%a8%8b%e5%ba%8f%e6%80%a7%e8%83%bd-ryJbRHRlbS\">\u5982\u4f55\u4f7f\u7528Redis\u547d\u4ee4\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd<\/h2>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8get%e5%91%bd%e4%bb%a4-ryJbRHRlbS\">1. \u4f7f\u7528GET\u547d\u4ee4<\/h3>\n<p>\u5728\u9700\u8981\u983b\u7e41\u8b80\u53d6\u67d0\u500b\u503c\u7684\u60c5\u6cc1\u4e0b\uff0c\u4f7f\u7528<code>GET<\/code>\u547d\u4ee4\u53ef\u4ee5\u5feb\u901f\u7372\u53d6\u6578\u64da\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>GET mykey<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u8fd4\u56de\u9375<code>mykey<\/code>\u5c0d\u61c9\u7684\u503c\u3002\u7531\u65bcRedis\u662f\u57fa\u65bc\u5167\u5b58\u7684\uff0c\u9019\u6a23\u7684\u64cd\u4f5c\u901f\u5ea6\u975e\u5e38\u5feb\uff0c\u80fd\u6709\u6548\u6e1b\u5c11\u6578\u64da\u5eab\u7684\u8ca0\u64d4\u3002<\/p>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8mget%e5%91%bd%e4%bb%a4-ryJbRHRlbS\">2. \u4f7f\u7528MGET\u547d\u4ee4<\/h3>\n<p>\u7576\u9700\u8981\u540c\u6642\u7372\u53d6\u591a\u500b\u9375\u7684\u503c\u6642\uff0c\u4f7f\u7528<code>MGET<\/code>\u547d\u4ee4\u53ef\u4ee5\u6e1b\u5c11\u591a\u6b21\u8acb\u6c42\u7684\u958b\u92b7\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>MGET key1 key2 key3<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u4e00\u6b21\u6027\u8fd4\u56de<code>key1<\/code>\u3001<code>key2<\/code>\u548c<code>key3<\/code>\u7684\u503c\uff0c\u5f9e\u800c\u63d0\u9ad8\u4e86\u6578\u64da\u7372\u53d6\u7684\u6548\u7387\u3002<\/p>\n<h3 id=\"3-%e4%bd%bf%e7%94%a8hget%e5%91%bd%e4%bb%a4-ryJbRHRlbS\">3. \u4f7f\u7528HGET\u547d\u4ee4<\/h3>\n<p>\u5c0d\u65bc\u5b58\u5132\u7d50\u69cb\u5316\u6578\u64da\u7684\u5834\u666f\uff0c\u4f7f\u7528\u54c8\u5e0c\u8868\u662f\u975e\u5e38\u5408\u9069\u7684\u3002<code>HGET<\/code>\u547d\u4ee4\u53ef\u4ee5\u5feb\u901f\u7372\u53d6\u54c8\u5e0c\u8868\u4e2d\u67d0\u500b\u5b57\u6bb5\u7684\u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>HGET myhash field1<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u8fd4\u56de\u54c8\u5e0c\u8868<code>myhash<\/code>\u4e2d<code>field1<\/code>\u7684\u503c\uff0c\u9019\u6a23\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u548c\u7372\u53d6\u7d50\u69cb\u5316\u6578\u64da\u3002<\/p>\n<h3 id=\"4-%e4%bd%bf%e7%94%a8lrange%e5%92%8czrange%e5%91%bd%e4%bb%a4-ryJbRHRlbS\">4. \u4f7f\u7528LRANGE\u548cZRANGE\u547d\u4ee4<\/h3>\n<p>\u5728\u8655\u7406\u5217\u8868\u548c\u6709\u5e8f\u96c6\u5408\u6642\uff0c<code>LRANGE<\/code>\u548c<code>ZRANGE<\/code>\u547d\u4ee4\u53ef\u4ee5\u7528\u4f86\u7372\u53d6\u6307\u5b9a\u7bc4\u570d\u7684\u5143\u7d20\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>LRANGE mylist 0 -1<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u8fd4\u56de\u5217\u8868<code>mylist<\/code>\u4e2d\u7684\u6240\u6709\u5143\u7d20\uff0c\u800c\uff1a<\/p>\n<pre><code>ZRANGE myzset 0 -1<\/code><\/pre>\n<p>\u5247\u8fd4\u56de\u6709\u5e8f\u96c6\u5408<code>myzset<\/code>\u4e2d\u7684\u6240\u6709\u5143\u7d20\u3002\u9019\u4e9b\u547d\u4ee4\u80fd\u5920\u9ad8\u6548\u5730\u8655\u7406\u5927\u91cf\u6578\u64da\uff0c\u63d0\u5347\u7a0b\u5e8f\u7684\u6574\u9ad4\u6027\u80fd\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ryJbRHRlbS\">\u7e3d\u7d50<\/h2>\n<p>Redis\u4f5c\u70ba\u4e00\u500b\u9ad8\u6548\u7684\u5167\u5b58\u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u547d\u4ee4\u4f86\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\uff0c\u7279\u5225\u662f\u5728\u6578\u64da\u7372\u53d6\u65b9\u9762\u3002\u901a\u904e\u5408\u7406\u4f7f\u7528<code>GET<\/code>\u3001<code>MGET<\/code>\u3001<code>HGET<\/code>\u3001<code>LRANGE<\/code>\u548c<code>ZRANGE<\/code>\u7b49\u547d\u4ee4\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u61c9\u7528\u7684\u97ff\u61c9\u901f\u5ea6\u548c\u6578\u64da\u8655\u7406\u80fd\u529b\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u6027\u80fd\u6578\u64da\u5b58\u53d6\u7684\u61c9\u7528\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\u81f3\u95dc\u91cd\u8981\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684<code><a href=\"https:\/\/server.hk\">VPS<\/a><\/code>\u89e3\u6c7a\u65b9\u6848\uff0cServer.HK\u63d0\u4f9b\u4e86\u591a\u7a2e\u9078\u64c7\uff0c\u5e6b\u52a9\u60a8\u63d0\u5347\u61c9\u7528\u6027\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5982\u4f55\u5229\u7528Redis\u547d\u4ee4\u63d0\u5347\u7a0b\u5e8f\u6027\u80fd\uff0c\u5feb\u901f\u7372\u53d6\u6578\u64da\uff0c\u512a\u5316\u61c9\u7528\u6548\u7387\uff0c\u5be6\u73fe\u9ad8\u6548\u6578\u64da\u8655\u7406\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-166757","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/166757","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=166757"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/166757\/revisions"}],"predecessor-version":[{"id":166758,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/166757\/revisions\/166758"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=166757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=166757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=166757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}