{"id":129683,"date":"2024-10-26T23:33:22","date_gmt":"2024-10-26T15:33:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/129683\/"},"modified":"2024-10-26T23:33:23","modified_gmt":"2024-10-26T15:33:23","slug":"redis%e7%82%ba%e4%bd%95%e5%a6%82%e6%ad%a4%e9%81%a9%e5%90%88%e5%81%9a%e5%bf%ab%e5%8f%96%ef%bc%88%e7%82%ba%e4%bb%80%e9%ba%bcredis%e8%83%bd%e5%81%9a%e5%bf%ab%e5%8f%96%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/129683\/","title":{"rendered":"Redis\u70ba\u4f55\u5982\u6b64\u9069\u5408\u505a\u5feb\u53d6\uff08\u70ba\u4ec0\u9ebcredis\u80fd\u505a\u5feb\u53d6\uff09"},"content":{"rendered":"<h1 id=\"redis%e7%82%ba%e4%bd%95%e5%a6%82%e6%ad%a4%e9%81%a9%e5%90%88%e5%81%9a%e5%bf%ab%e5%8f%96%ef%bc%88%e7%82%ba%e4%bb%80%e9%ba%bcredis%e8%83%bd%e5%81%9a%e5%bf%ab%e5%8f%96%ef%bc%89-fCXpWtDkdk\">Redis\u70ba\u4f55\u5982\u6b64\u9069\u5408\u505a\u5feb\u53d6\uff08\u70ba\u4ec0\u9ebcredis\u80fd\u505a\u5feb\u53d6\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u8def\u61c9\u7528\u4e2d\uff0c\u6027\u80fd\u548c\u901f\u5ea6\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u96a8\u8457\u7528\u6236\u9700\u6c42\u7684\u589e\u52a0\uff0c\u958b\u767c\u8005\u9700\u8981\u5c0b\u627e\u6709\u6548\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u63d0\u5347\u61c9\u7528\u7684\u97ff\u61c9\u901f\u5ea6\u548c\u8655\u7406\u80fd\u529b\u3002Redis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u5feb\u53d6\u89e3\u6c7a\u65b9\u6848\uff0c\u56e0\u5176\u5353\u8d8a\u7684\u6027\u80fd\u548c\u9748\u6d3b\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u95dc\u6ce8\u3002\u672c\u6587\u5c07\u63a2\u8a0eRedis\u70ba\u4f55\u5982\u6b64\u9069\u5408\u7528\u4f5c\u5feb\u53d6\u7cfb\u7d71\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afredis%ef%bc%9f-fCXpWtDkdk\">\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\u4e3b\u8981\u7528\u65bc\u6578\u64da\u7684\u5feb\u53d6\u548c\u5b58\u5132\u3002\u5b83\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\uff0c\u4e26\u4e14\u80fd\u5920\u5728\u5167\u5b58\u4e2d\u9032\u884c\u5feb\u901f\u7684\u6578\u64da\u8b80\u53d6\u548c\u5beb\u5165\u64cd\u4f5c\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e6%80%a7%e8%83%bd%e5%84%aa%e5%8b%a2-fCXpWtDkdk\">Redis\u7684\u6027\u80fd\u512a\u52e2<\/h2>\n<p>Redis\u7684\u6027\u80fd\u512a\u52e2\u4e3b\u8981\u9ad4\u73fe\u5728\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\u6975\u5feb\u3002\u6839\u64da\u5b98\u65b9\u6587\u6a94\uff0cRedis\u7684\u64cd\u4f5c\u5ef6\u9072\u901a\u5e38\u5728\u5fae\u79d2\u7d1a\u5225\u3002<\/li>\n<li><strong>\u55ae\u7dda\u7a0b\u67b6\u69cb\uff1a<\/strong>Redis\u63a1\u7528\u55ae\u7dda\u7a0b\u6a21\u578b\uff0c\u9019\u610f\u5473\u8457\u5b83\u4e0d\u6703\u53d7\u5230\u591a\u7dda\u7a0b\u74b0\u5883\u4e2d\u9396\u7684\u5f71\u97ff\uff0c\u5f9e\u800c\u6e1b\u5c11\u4e86\u4e0a\u4e0b\u6587\u5207\u63db\u7684\u958b\u92b7\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\u958b\u767c\u8005\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<\/ul>\n<h2 id=\"%e5%bf%ab%e5%8f%96%e7%9a%84%e5%bf%85%e8%a6%81%e6%80%a7-fCXpWtDkdk\">\u5feb\u53d6\u7684\u5fc5\u8981\u6027<\/h2>\n<p>\u5728\u8a31\u591a\u61c9\u7528\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u8b80\u53d6\u64cd\u4f5c\u5f80\u5f80\u662f\u6027\u80fd\u74f6\u9838\u3002\u7576\u7528\u6236\u8acb\u6c42\u6578\u64da\u6642\uff0c\u82e5\u6bcf\u6b21\u90fd\u9700\u8981\u5f9e\u6578\u64da\u5eab\u4e2d\u8b80\u53d6\uff0c\u5c07\u6703\u5c0e\u81f4\u5ef6\u9072\u548c\u8cc7\u6e90\u6d6a\u8cbb\u3002\u5feb\u53d6\u6280\u8853\u7684\u51fa\u73fe\u6b63\u662f\u70ba\u4e86\u89e3\u6c7a\u9019\u4e00\u554f\u984c\u3002\u901a\u904e\u5c07\u983b\u7e41\u8a2a\u554f\u7684\u6578\u64da\u5b58\u5132\u5728\u5feb\u53d6\u4e2d\uff0c\u61c9\u7528\u53ef\u4ee5\u5feb\u901f\u97ff\u61c9\u7528\u6236\u8acb\u6c42\uff0c\u5f9e\u800c\u63d0\u5347\u6574\u9ad4\u6027\u80fd\u3002<\/p>\n<h2 id=\"redis%e4%bd%9c%e7%82%ba%e5%bf%ab%e5%8f%96%e7%9a%84%e5%84%aa%e5%8b%a2-fCXpWtDkdk\">Redis\u4f5c\u70ba\u5feb\u53d6\u7684\u512a\u52e2<\/h2>\n<p>\u4f7f\u7528Redis\u4f5c\u70ba\u5feb\u53d6\u7cfb\u7d71\u6709\u4ee5\u4e0b\u5e7e\u500b\u986f\u8457\u512a\u52e2\uff1a<\/p>\n<ul>\n<li><strong>\u7c21\u55ae\u6613\u7528\uff1a<\/strong>Redis\u63d0\u4f9b\u4e86\u7c21\u55ae\u7684API\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u8f15\u9b06\u5730\u5c07\u5176\u96c6\u6210\u5230\u73fe\u6709\u7684\u61c9\u7528\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684Python\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Redis\u9032\u884c\u5feb\u53d6\uff1a<\/li>\n<\/ul>\n<pre><code>import redis\n\n# \u9023\u63a5\u5230Redis\u670d\u52d9\u5668\nr = redis.Redis(host='localhost', port=6379, db=0)\n\n# \u8a2d\u7f6e\u5feb\u53d6\nr.set('key', 'value')\n\n# \u7372\u53d6\u5feb\u53d6\nvalue = r.get('key')\nprint(value)  # \u8f38\u51fa: b'value'<\/code><\/pre>\n<ul>\n<li><strong>\u6301\u4e45\u5316\u9078\u9805\uff1a<\/strong>\u96d6\u7136Redis\u4e3b\u8981\u7528\u65bc\u5167\u5b58\u5feb\u53d6\uff0c\u4f46\u5b83\u4e5f\u63d0\u4f9b\u4e86\u6301\u4e45\u5316\u9078\u9805\uff0c\u5141\u8a31\u7528\u6236\u5c07\u6578\u64da\u6301\u4e45\u5316\u5230\u78c1\u789f\u4e2d\uff0c\u9019\u6a23\u5373\u4f7f\u5728\u670d\u52d9\u5668\u91cd\u555f\u5f8c\uff0c\u6578\u64da\u4e5f\u4e0d\u6703\u4e1f\u5931\u3002<\/li>\n<li><strong>\u652f\u6301\u5206\u4f48\u5f0f\u5feb\u53d6\uff1a<\/strong>Redis\u652f\u6301\u4e3b\u5f9e\u8907\u88fd\u548c\u5206\u7247\uff0c\u9019\u4f7f\u5f97\u5b83\u80fd\u5920\u5728\u5206\u4f48\u5f0f\u7cfb\u7d71\u4e2d\u6709\u6548\u5730\u7ba1\u7406\u5feb\u53d6\uff0c\u5f9e\u800c\u63d0\u9ad8\u53ef\u64f4\u5c55\u6027\u548c\u53ef\u9760\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-fCXpWtDkdk\">\u7d50\u8ad6<\/h2>\n<p>\u7e3d\u7684\u4f86\u8aaa\uff0cRedis\u56e0\u5176\u5353\u8d8a\u7684\u6027\u80fd\u3001\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\u548c\u7c21\u55ae\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u4f7f\u5176\u6210\u70ba\u4e00\u500b\u7406\u60f3\u7684\u5feb\u53d6\u89e3\u6c7a\u65b9\u6848\u3002\u7121\u8ad6\u662f\u7528\u65bc\u63d0\u5347\u7db2\u7ad9\u7684\u97ff\u61c9\u901f\u5ea6\uff0c\u9084\u662f\u7528\u65bc\u6e1b\u5c11\u6578\u64da\u5eab\u7684\u8ca0\u64d4\uff0cRedis\u90fd\u80fd\u5920\u63d0\u4f9b\u6709\u6548\u7684\u652f\u6301\u3002\u5c0d\u65bc\u5e0c\u671b\u63d0\u5347\u61c9\u7528\u6027\u80fd\u7684\u958b\u767c\u8005\u4f86\u8aaa\uff0cRedis\u7121\u7591\u662f\u4e00\u500b\u503c\u5f97\u8003\u616e\u7684\u9078\u64c7\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u90e8\u7f72Redis\uff0cServer.HK\u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u5e6b\u52a9\u60a8\u8f15\u9b06\u5be6\u73fe\u9ad8\u6027\u80fd\u7684\u61c9\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis\u4ee5\u5176\u9ad8\u6548\u7684\u5167\u5b58\u5b58\u5132\u3001\u5feb\u901f\u7684\u6578\u64da\u8a2a\u554f\u548c\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\uff0c\u6210\u70ba\u7406\u60f3\u7684\u5feb\u53d6\u89e3\u6c7a\u65b9\u6848\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-129683","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/129683","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=129683"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/129683\/revisions"}],"predecessor-version":[{"id":129684,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/129683\/revisions\/129684"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=129683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=129683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=129683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}