{"id":97454,"date":"2024-10-20T18:06:17","date_gmt":"2024-10-20T10:06:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/97454\/"},"modified":"2024-10-20T18:06:18","modified_gmt":"2024-10-20T10:06:18","slug":"redis-%e5%bc%b7%e5%a4%a7%e7%9a%84%e8%ae%80%e5%af%ab%e8%83%bd%e5%8a%9b%ef%bc%88redis%e8%ae%80%e5%af%ab%e8%83%bd%e5%8a%9b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/97454\/","title":{"rendered":"Redis \u5f37\u5927\u7684\u8b80\u5beb\u80fd\u529b\uff08redis\u8b80\u5beb\u80fd\u529b\uff09"},"content":{"rendered":"<h1 id=\"redis-%e5%bc%b7%e5%a4%a7%e7%9a%84%e8%ae%80%e5%af%ab%e8%83%bd%e5%8a%9b-wOlgtwiZqS\">Redis \u5f37\u5927\u7684\u8b80\u5beb\u80fd\u529b<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u7684\u8b80\u53d6\u548c\u5beb\u5165\u901f\u5ea6\u5c0d\u65bc\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u81f3\u95dc\u91cd\u8981\u3002Redis\uff0c\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u9375\u503c\u5b58\u5132\u7cfb\u7d71\uff0c\u4ee5\u5176\u5353\u8d8a\u7684\u8b80\u5beb\u80fd\u529b\u800c\u805e\u540d\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eRedis\u7684\u8b80\u5beb\u80fd\u529b\uff0c\u4e26\u5206\u6790\u5176\u80cc\u5f8c\u7684\u6280\u8853\u539f\u7406\u53ca\u61c9\u7528\u5834\u666f\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5-wOlgtwiZqS\">Redis\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>Redis\uff08Remote Dictionary Server\uff09\u662f\u4e00\u500b\u958b\u6e90\u7684\u5167\u5b58\u6578\u64da\u7d50\u69cb\u5b58\u5132\u7cfb\u7d71\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\u6578\u64da\u5b58\u5132\u5728\u5167\u5b58\u4e2d\uff0cRedis\u80fd\u5920\u63d0\u4f9b\u6975\u5feb\u7684\u8b80\u53d6\u548c\u5beb\u5165\u901f\u5ea6\uff0c\u901a\u5e38\u5728\u6beb\u79d2\u7d1a\u5225\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e8%ae%80%e5%af%ab%e6%80%a7%e8%83%bd-wOlgtwiZqS\">Redis\u7684\u8b80\u5beb\u6027\u80fd<\/h2>\n<p>Redis\u7684\u8b80\u5beb\u6027\u80fd\u4e3b\u8981\u5f97\u76ca\u65bc\u4ee5\u4e0b\u5e7e\u500b\u65b9\u9762\uff1a<\/p>\n<ul>\n<li><strong>\u5167\u5b58\u5b58\u5132\uff1a<\/strong>Redis\u5c07\u6578\u64da\u5b58\u5132\u5728\u5167\u5b58\u4e2d\uff0c\u9019\u4f7f\u5f97\u6578\u64da\u7684\u8b80\u53d6\u548c\u5beb\u5165\u901f\u5ea6\u9060\u8d85\u65bc\u50b3\u7d71\u7684\u78c1\u789f\u5b58\u5132\u7cfb\u7d71\u3002<\/li>\n<li><strong>\u55ae\u7dda\u7a0b\u67b6\u69cb\uff1a<\/strong>Redis\u4f7f\u7528\u55ae\u7dda\u7a0b\u6a21\u578b\u4f86\u8655\u7406\u8acb\u6c42\uff0c\u9019\u907f\u514d\u4e86\u591a\u7dda\u7a0b\u74b0\u5883\u4e0b\u7684\u4e0a\u4e0b\u6587\u5207\u63db\u958b\u92b7\uff0c\u5f9e\u800c\u63d0\u9ad8\u4e86\u6027\u80fd\u3002<\/li>\n<li><strong>\u9ad8\u6548\u7684\u6578\u64da\u7d50\u69cb\uff1a<\/strong>Redis\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u9019\u4f7f\u5f97\u7528\u6236\u53ef\u4ee5\u6839\u64da\u5177\u9ad4\u9700\u6c42\u9078\u64c7\u6700\u5408\u9069\u7684\u6578\u64da\u985e\u578b\uff0c\u5f9e\u800c\u63d0\u9ad8\u64cd\u4f5c\u6548\u7387\u3002<\/li>\n<li><strong>\u6301\u4e45\u5316\u9078\u9805\uff1a<\/strong>\u96d6\u7136Redis\u4e3b\u8981\u662f\u5167\u5b58\u6578\u64da\u5eab\uff0c\u4f46\u5b83\u63d0\u4f9b\u4e86RDB\u548cAOF\u5169\u7a2e\u6301\u4e45\u5316\u6a5f\u5236\uff0c\u80fd\u5920\u5728\u7cfb\u7d71\u91cd\u555f\u5f8c\u6062\u5fa9\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e8%ae%80%e5%8f%96%e6%80%a7%e8%83%bd%e5%88%86%e6%9e%90-wOlgtwiZqS\">\u8b80\u53d6\u6027\u80fd\u5206\u6790<\/h2>\n<p>\u5728Redis\u4e2d\uff0c\u8b80\u53d6\u64cd\u4f5c\u7684\u6027\u80fd\u975e\u5e38\u9ad8\u3002\u6839\u64da\u5b98\u65b9\u6587\u6a94\uff0cRedis\u7684\u8b80\u53d6\u5ef6\u9072\u901a\u5e38\u57281\u6beb\u79d2\u4ee5\u5167\u3002\u9019\u662f\u56e0\u70baRedis\u4f7f\u7528\u4e86\u9ad8\u6548\u7684\u6578\u64da\u7d50\u69cb\u548c\u5167\u5b58\u7ba1\u7406\u6280\u8853\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u8b80\u53d6\u64cd\u4f5c\u793a\u4f8b\uff1a<\/p>\n<pre><code>SET key \"value\"\nGET key<\/code><\/pre>\n<p>\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528SET\u547d\u4ee4\u5c07\u4e00\u500b\u9375\u503c\u5c0d\u5b58\u5132\u5230Redis\u4e2d\uff0c\u7136\u5f8c\u4f7f\u7528GET\u547d\u4ee4\u4f86\u8b80\u53d6\u8a72\u503c\u3002\u7531\u65bc\u6240\u6709\u64cd\u4f5c\u90fd\u662f\u5728\u5167\u5b58\u4e2d\u9032\u884c\u7684\uff0c\u56e0\u6b64\u8b80\u53d6\u901f\u5ea6\u975e\u5e38\u5feb\u3002<\/p>\n<h2 id=\"%e5%af%ab%e5%85%a5%e6%80%a7%e8%83%bd%e5%88%86%e6%9e%90-wOlgtwiZqS\">\u5beb\u5165\u6027\u80fd\u5206\u6790<\/h2>\n<p>Redis\u7684\u5beb\u5165\u6027\u80fd\u540c\u6a23\u51fa\u8272\u3002\u6839\u64da\u6e2c\u8a66\uff0cRedis\u6bcf\u79d2\u53ef\u4ee5\u8655\u7406\u6578\u5341\u842c\u6b21\u7684\u5beb\u5165\u64cd\u4f5c\u3002\u9019\u4f7f\u5f97\u5b83\u975e\u5e38\u9069\u5408\u9700\u8981\u9ad8\u983b\u5beb\u5165\u7684\u61c9\u7528\u5834\u666f\uff0c\u5982\u65e5\u8a8c\u8a18\u9304\u548c\u5373\u6642\u6578\u64da\u5206\u6790\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u5beb\u5165\u64cd\u4f5c\u793a\u4f8b\uff1a<\/p>\n<pre><code>LPUSH mylist \"value1\"\nLPUSH mylist \"value2\"<\/code><\/pre>\n<p>\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528LPUSH\u547d\u4ee4\u5c07\u591a\u500b\u503c\u63a8\u5165\u5217\u8868\u4e2d\u3002Redis\u7684\u9ad8\u6548\u5beb\u5165\u80fd\u529b\u4f7f\u5f97\u9019\u4e9b\u64cd\u4f5c\u80fd\u5920\u5728\u6975\u77ed\u7684\u6642\u9593\u5167\u5b8c\u6210\u3002<\/p>\n<h2 id=\"%e6%87%89%e7%94%a8%e5%a0%b4%e6%99%af-wOlgtwiZqS\">\u61c9\u7528\u5834\u666f<\/h2>\n<p>\u7531\u65bcRedis\u7684\u5f37\u5927\u8b80\u5beb\u80fd\u529b\uff0c\u5b83\u88ab\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u5834\u666f\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u7de9\u5b58\u7cfb\u7d71\uff1a<\/strong>\u5229\u7528Redis\u4f5c\u70ba\u7de9\u5b58\u5c64\uff0c\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u61c9\u7528\u7a0b\u5e8f\u7684\u97ff\u61c9\u901f\u5ea6\u3002<\/li>\n<li><strong>\u5373\u6642\u6578\u64da\u5206\u6790\uff1a<\/strong>\u5728\u9700\u8981\u5feb\u901f\u8655\u7406\u5927\u91cf\u6578\u64da\u7684\u5834\u666f\u4e2d\uff0cRedis\u80fd\u5920\u63d0\u4f9b\u5373\u6642\u7684\u6578\u64da\u8b80\u53d6\u548c\u5beb\u5165\u80fd\u529b\u3002<\/li>\n<li><strong>\u6d88\u606f\u968a\u5217\uff1a<\/strong>Redis\u7684\u5217\u8868\u548c\u767c\u5e03\/\u8a02\u95b1\u529f\u80fd\u4f7f\u5176\u6210\u70ba\u4e00\u500b\u7406\u60f3\u7684\u6d88\u606f\u968a\u5217\u89e3\u6c7a\u65b9\u6848\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-wOlgtwiZqS\">\u7e3d\u7d50<\/h2>\n<p>Redis\u4ee5\u5176\u5353\u8d8a\u7684\u8b80\u5beb\u80fd\u529b\uff0c\u6210\u70ba\u4e86\u8a31\u591a\u61c9\u7528\u7a0b\u5e8f\u7684\u9996\u9078\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u3002\u7121\u8ad6\u662f\u4f5c\u70ba\u7de9\u5b58\u7cfb\u7d71\u9084\u662f\u5373\u6642\u6578\u64da\u5206\u6790\u5de5\u5177\uff0cRedis\u90fd\u80fd\u5920\u63d0\u4f9b\u9ad8\u6548\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\u9078\u64c7\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u90e8\u7f72Redis\uff0c\u5145\u5206\u767c\u63ee\u5176\u5f37\u5927\u7684\u8b80\u5beb\u80fd\u529b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Redis\u7684\u5f37\u5927\u8b80\u5beb\u80fd\u529b\uff0c\u5be6\u73fe\u9ad8\u6548\u6578\u64da\u5b58\u53d6\uff0c\u63d0\u5347\u61c9\u7528\u6027\u80fd\uff0c\u6eff\u8db3\u73fe\u4ee3\u9700\u6c42\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-97454","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/97454","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=97454"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/97454\/revisions"}],"predecessor-version":[{"id":97455,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/97454\/revisions\/97455"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=97454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=97454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=97454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}