{"id":181512,"date":"2024-11-09T17:40:20","date_gmt":"2024-11-09T09:40:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/181512\/"},"modified":"2024-11-09T17:40:21","modified_gmt":"2024-11-09T09:40:21","slug":"%e6%b7%b1%e5%85%a5%e6%b7%ba%e5%87%baredis%e7%ae%97%e6%b3%95%e8%a7%a3%e8%ae%80%ef%bc%88redis%e7%ae%97%e6%b3%95%e8%a9%b3%e8%a7%a3%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/181512\/","title":{"rendered":"\u6df1\u5165\u6dfa\u51faRedis\u7b97\u6cd5\u89e3\u8b80\uff08redis\u7b97\u6cd5\u8a73\u89e3\uff09"},"content":{"rendered":"<h1 id=\"%e6%b7%b1%e5%85%a5%e6%b7%ba%e5%87%baredis%e7%ae%97%e6%b3%95%e8%a7%a3%e8%ae%80%ef%bc%88redis%e7%ae%97%e6%b3%95%e8%a9%b3%e8%a7%a3%ef%bc%89-lqSrobOJdP\">\u6df1\u5165\u6dfa\u51faRedis\u7b97\u6cd5\u89e3\u8b80\uff08redis\u7b97\u6cd5\u8a73\u89e3\uff09<\/h1>\n<p>Redis\u662f\u4e00\u500b\u9ad8\u6548\u80fd\u7684\u9375\u503c\u6578\u64da\u5eab\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u5834\u666f\uff0c\u5982\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u6578\u64da\u6301\u4e45\u5316\u7b49\u3002\u5176\u80cc\u5f8c\u7684\u7b97\u6cd5\u8a2d\u8a08\u662f\u5176\u6027\u80fd\u7684\u95dc\u9375\u6240\u5728\u3002\u672c\u6587\u5c07\u6df1\u5165\u6dfa\u51fa\u5730\u89e3\u8b80Redis\u7684\u6838\u5fc3\u7b97\u6cd5\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u5176\u904b\u4f5c\u539f\u7406\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e6%95%b8%e6%93%9a%e7%b5%90%e6%a7%8b-lqSrobOJdP\">Redis\u7684\u6578\u64da\u7d50\u69cb<\/h2>\n<p>Redis\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u5305\u62ec\u5b57\u7b26\u4e32\u3001\u54c8\u5e0c\u3001\u5217\u8868\u3001\u96c6\u5408\u548c\u6709\u5e8f\u96c6\u5408\u3002\u6bcf\u7a2e\u6578\u64da\u7d50\u69cb\u90fd\u6709\u5176\u7279\u5b9a\u7684\u7b97\u6cd5\u548c\u61c9\u7528\u5834\u666f\u3002<\/p>\n<ul>\n<li><strong>\u5b57\u7b26\u4e32\uff08String\uff09<\/strong>: \u6700\u57fa\u672c\u7684\u6578\u64da\u985e\u578b\uff0c\u652f\u6301\u4e8c\u9032\u5236\u5b89\u5168\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u3002<\/li>\n<li><strong>\u54c8\u5e0c\uff08Hash\uff09<\/strong>: \u7528\u65bc\u5b58\u5132\u5c0d\u8c61\u7684\u5b57\u6bb5\u548c\u5c0d\u61c9\u503c\uff0c\u9069\u5408\u5b58\u5132\u5c0f\u578b\u5c0d\u8c61\u3002<\/li>\n<li><strong>\u5217\u8868\uff08List\uff09<\/strong>: \u6309\u7167\u63d2\u5165\u9806\u5e8f\u5b58\u5132\u7684\u5b57\u7b26\u4e32\u5e8f\u5217\uff0c\u652f\u6301\u5f9e\u5169\u7aef\u63d2\u5165\u548c\u522a\u9664\u3002<\/li>\n<li><strong>\u96c6\u5408\uff08Set\uff09<\/strong>: \u4e0d\u5141\u8a31\u91cd\u8907\u7684\u5b57\u7b26\u4e32\u96c6\u5408\uff0c\u652f\u6301\u96c6\u5408\u904b\u7b97\u3002<\/li>\n<li><strong>\u6709\u5e8f\u96c6\u5408\uff08Sorted Set\uff09<\/strong>: \u6bcf\u500b\u5143\u7d20\u90fd\u6709\u4e00\u500b\u5206\u6578\uff0c\u6839\u64da\u5206\u6578\u81ea\u52d5\u6392\u5e8f\u3002<\/li>\n<\/ul>\n<h2 id=\"redis%e7%9a%84%e6%a0%b8%e5%bf%83%e7%ae%97%e6%b3%95-lqSrobOJdP\">Redis\u7684\u6838\u5fc3\u7b97\u6cd5<\/h2>\n<h3 id=\"1-%e5%96%ae%e7%b7%9a%e7%a8%8b%e6%a8%a1%e5%9e%8b-lqSrobOJdP\">1. \u55ae\u7dda\u7a0b\u6a21\u578b<\/h3>\n<p>Redis\u63a1\u7528\u55ae\u7dda\u7a0b\u6a21\u578b\u4f86\u8655\u7406\u8acb\u6c42\uff0c\u9019\u610f\u5473\u8457\u6240\u6709\u7684\u8acb\u6c42\u90fd\u662f\u5728\u540c\u4e00\u500b\u7dda\u7a0b\u4e2d\u4f9d\u6b21\u8655\u7406\u3002\u9019\u6a23\u7684\u8a2d\u8a08\u907f\u514d\u4e86\u591a\u7dda\u7a0b\u74b0\u5883\u4e0b\u7684\u4e0a\u4e0b\u6587\u5207\u63db\u548c\u9396\u7af6\u722d\u554f\u984c\uff0c\u5f9e\u800c\u63d0\u9ad8\u4e86\u6027\u80fd\u3002\u96d6\u7136\u55ae\u7dda\u7a0b\u6a21\u578b\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\u53ef\u80fd\u6703\u6210\u70ba\u74f6\u9838\uff0c\u4f46Redis\u901a\u904e\u975e\u963b\u585eI\/O\u548c\u4e8b\u4ef6\u9a45\u52d5\u7684\u65b9\u5f0f\u4f86\u8655\u7406\u5927\u91cf\u7684\u4e26\u767c\u8acb\u6c42\u3002<\/p>\n<h3 id=\"2-%e5%85%a7%e5%ad%98%e7%ae%a1%e7%90%86-lqSrobOJdP\">2. \u5167\u5b58\u7ba1\u7406<\/h3>\n<p>Redis\u5c07\u6240\u6709\u6578\u64da\u5b58\u5132\u5728\u5167\u5b58\u4e2d\uff0c\u9019\u4f7f\u5f97\u5176\u8b80\u53d6\u548c\u5beb\u5165\u901f\u5ea6\u6975\u5feb\u3002\u70ba\u4e86\u6709\u6548\u7ba1\u7406\u5167\u5b58\uff0cRedis\u4f7f\u7528\u4e86\u591a\u7a2e\u5167\u5b58\u5206\u914d\u5668\uff0c\u5982jemalloc\u548clibc\u3002\u9019\u4e9b\u5206\u914d\u5668\u80fd\u5920\u6839\u64da\u4e0d\u540c\u7684\u4f7f\u7528\u5834\u666f\u9032\u884c\u512a\u5316\uff0c\u5f9e\u800c\u63d0\u9ad8\u5167\u5b58\u7684\u4f7f\u7528\u6548\u7387\u3002<\/p>\n<h3 id=\"3-%e6%8c%81%e4%b9%85%e5%8c%96%e6%a9%9f%e5%88%b6-lqSrobOJdP\">3. \u6301\u4e45\u5316\u6a5f\u5236<\/h3>\n<p>\u96d6\u7136Redis\u4e3b\u8981\u662f\u4e00\u500b\u5167\u5b58\u6578\u64da\u5eab\uff0c\u4f46\u5b83\u4e5f\u63d0\u4f9b\u4e86\u6301\u4e45\u5316\u7684\u9078\u9805\uff0c\u4ee5\u9632\u6b62\u6578\u64da\u4e1f\u5931\u3002Redis\u652f\u6301\u5169\u7a2e\u6301\u4e45\u5316\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li><strong>RDB\uff08\u5feb\u7167\uff09<\/strong>: \u5b9a\u671f\u5c07\u6578\u64da\u5feb\u7167\u4fdd\u5b58\u5230\u78c1\u789f\u4e2d\u3002<\/li>\n<li><strong>AOF\uff08\u8ffd\u52a0\u6587\u4ef6\uff09<\/strong>: \u5c07\u6bcf\u6b21\u5beb\u64cd\u4f5c\u8ffd\u52a0\u5230\u4e00\u500b\u65e5\u8a8c\u6587\u4ef6\u4e2d\u3002<\/li>\n<\/ul>\n<p>\u9019\u5169\u7a2e\u65b9\u5f0f\u53ef\u4ee5\u6839\u64da\u9700\u6c42\u9032\u884c\u9078\u64c7\uff0c\u4e26\u4e14\u53ef\u4ee5\u540c\u6642\u4f7f\u7528\uff0c\u4ee5\u9054\u5230\u66f4\u9ad8\u7684\u6578\u64da\u5b89\u5168\u6027\u3002<\/p>\n<h3 id=\"4-%e6%95%b8%e6%93%9a%e9%81%8e%e6%9c%9f%e5%92%8c%e6%b7%98%e6%b1%b0%e7%ad%96%e7%95%a5-lqSrobOJdP\">4. \u6578\u64da\u904e\u671f\u548c\u6dd8\u6c70\u7b56\u7565<\/h3>\n<p>Redis\u652f\u6301\u8a2d\u7f6e\u9375\u7684\u904e\u671f\u6642\u9593\uff0c\u4e26\u63d0\u4f9b\u591a\u7a2e\u6578\u64da\u6dd8\u6c70\u7b56\u7565\uff0c\u5982LRU\uff08\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff09\u3001LFU\uff08\u6700\u4e0d\u5e38\u4f7f\u7528\uff09\u7b49\u3002\u9019\u4e9b\u7b56\u7565\u80fd\u5920\u6709\u6548\u7ba1\u7406\u5167\u5b58\uff0c\u78ba\u4fdd\u7cfb\u7d71\u5728\u9ad8\u8ca0\u8f09\u4e0b\u4ecd\u80fd\u7a69\u5b9a\u904b\u884c\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e6%87%89%e7%94%a8%e5%a0%b4%e6%99%af-lqSrobOJdP\">Redis\u7684\u61c9\u7528\u5834\u666f<\/h2>\n<p>\u7531\u65bc\u5176\u9ad8\u6548\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\uff0cRedis\u88ab\u5ee3\u6cdb\u61c9\u7528\u65bc\u4ee5\u4e0b\u5834\u666f\uff1a<\/p>\n<ul>\n<li>\u7de9\u5b58\u7cfb\u7d71\uff1a\u63d0\u9ad8\u6578\u64da\u8b80\u53d6\u901f\u5ea6\uff0c\u6e1b\u5c11\u6578\u64da\u5eab\u58d3\u529b\u3002<\/li>\n<li>\u6d88\u606f\u968a\u5217\uff1a\u652f\u6301\u9ad8\u6548\u7684\u6d88\u606f\u50b3\u905e\u548c\u8655\u7406\u3002<\/li>\n<li>\u5be6\u6642\u6578\u64da\u5206\u6790\uff1a\u5feb\u901f\u8655\u7406\u548c\u5206\u6790\u5927\u91cf\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-lqSrobOJdP\">\u7e3d\u7d50<\/h2>\n<p>Redis\u7684\u9ad8\u6548\u6027\u80fd\u6e90\u65bc\u5176\u7368\u7279\u7684\u7b97\u6cd5\u8a2d\u8a08\u548c\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\u3002\u901a\u904e\u6df1\u5165\u7406\u89e3Redis\u7684\u6838\u5fc3\u7b97\u6cd5\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u597d\u5730\u5229\u7528\u9019\u4e00\u5f37\u5927\u7684\u5de5\u5177\u4f86\u89e3\u6c7a\u5404\u7a2e\u5be6\u969b\u554f\u984c\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u7a69\u5b9a\u4e14\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u7684\u670d\u52d9\u5c07\u662f\u60a8\u7684\u7406\u60f3\u9078\u64c7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u6dfa\u51faRedis\u7b97\u6cd5\u89e3\u8b80\uff0c\u5168\u9762\u89e3\u6790Redis\u80cc\u5f8c\u7684\u7b97\u6cd5\u539f\u7406\uff0c\u5e6b\u52a9\u8b80\u8005\u8f15\u9b06\u638c\u63e1\u9ad8\u6548\u6578\u64da\u8655\u7406\u6280\u8853\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-181512","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/181512","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=181512"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/181512\/revisions"}],"predecessor-version":[{"id":181513,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/181512\/revisions\/181513"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=181512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=181512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=181512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}