{"id":128575,"date":"2024-10-26T15:11:17","date_gmt":"2024-10-26T07:11:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/128575\/"},"modified":"2024-10-26T15:11:18","modified_gmt":"2024-10-26T07:11:18","slug":"redis%e5%af%a6%e7%8f%be%e9%ab%98%e6%95%88%e6%b7%98%e6%b1%b0%e5%bf%ab%e5%8f%96%ef%bc%88redis%e6%b7%98%e6%b1%b0%e5%bf%ab%e5%8f%96%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/128575\/","title":{"rendered":"Redis\u5be6\u73fe\u9ad8\u6548\u6dd8\u6c70\u5feb\u53d6\uff08redis\u6dd8\u6c70\u5feb\u53d6\uff09"},"content":{"rendered":"<h1 id=\"redis%e5%af%a6%e7%8f%be%e9%ab%98%e6%95%88%e6%b7%98%e6%b1%b0%e5%bf%ab%e5%8f%96%ef%bc%88redis%e6%b7%98%e6%b1%b0%e5%bf%ab%e5%8f%96%ef%bc%89-iukkFfpeJJ\">Redis\u5be6\u73fe\u9ad8\u6548\u6dd8\u6c70\u5feb\u53d6\uff08redis\u6dd8\u6c70\u5feb\u53d6\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0c\u5feb\u53d6\u6280\u8853\u5df2\u6210\u70ba\u63d0\u5347\u61c9\u7528\u6027\u80fd\u7684\u95dc\u9375\u56e0\u7d20\u4e4b\u4e00\u3002Redis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u5167\u5b58\u6578\u64da\u5eab\uff0c\u4e0d\u50c5\u63d0\u4f9b\u4e86\u5feb\u901f\u7684\u6578\u64da\u5b58\u53d6\u80fd\u529b\uff0c\u9084\u5177\u5099\u591a\u7a2e\u5feb\u53d6\u6dd8\u6c70\u7b56\u7565\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u6709\u6548\u7ba1\u7406\u5167\u5b58\u4f7f\u7528\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eRedis\u7684\u5feb\u53d6\u6dd8\u6c70\u6a5f\u5236\u53ca\u5176\u5be6\u73fe\u65b9\u5f0f\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e5%bf%ab%e5%8f%96%e6%b7%98%e6%b1%b0%ef%bc%9f-iukkFfpeJJ\">\u4ec0\u9ebc\u662f\u5feb\u53d6\u6dd8\u6c70\uff1f<\/h2>\n<p>\u5feb\u53d6\u6dd8\u6c70\u662f\u6307\u5728\u5feb\u53d6\u7a7a\u9593\u4e0d\u8db3\u6642\uff0c\u7cfb\u7d71\u81ea\u52d5\u79fb\u9664\u67d0\u4e9b\u6578\u64da\u4ee5\u91cb\u653e\u5167\u5b58\u7684\u904e\u7a0b\u3002\u9019\u4e00\u904e\u7a0b\u5c0d\u65bc\u4fdd\u6301\u7cfb\u7d71\u6027\u80fd\u81f3\u95dc\u91cd\u8981\uff0c\u56e0\u70ba\u5b83\u78ba\u4fdd\u4e86\u6700\u5e38\u7528\u7684\u6578\u64da\u80fd\u5920\u4fdd\u7559\u5728\u5feb\u53d6\u4e2d\uff0c\u800c\u4e0d\u5e38\u7528\u7684\u6578\u64da\u5247\u88ab\u79fb\u9664\u3002<\/p>\n<h2 id=\"redis%e7%9a%84%e5%bf%ab%e5%8f%96%e6%b7%98%e6%b1%b0%e7%ad%96%e7%95%a5-iukkFfpeJJ\">Redis\u7684\u5feb\u53d6\u6dd8\u6c70\u7b56\u7565<\/h2>\n<p>Redis\u63d0\u4f9b\u4e86\u591a\u7a2e\u5feb\u53d6\u6dd8\u6c70\u7b56\u7565\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u6839\u64da\u5177\u9ad4\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u7b56\u7565\u3002\u4ee5\u4e0b\u662f\u5e7e\u7a2e\u4e3b\u8981\u7684\u6dd8\u6c70\u7b56\u7565\uff1a<\/p>\n<ul>\n<li><strong>noeviction<\/strong>\uff1a\u7576\u5167\u5b58\u4e0d\u8db3\u6642\uff0c\u7121\u6cd5\u518d\u5beb\u5165\u65b0\u6578\u64da\uff0c\u6703\u8fd4\u56de\u932f\u8aa4\u3002<\/li>\n<li><strong>allkeys-lru<\/strong>\uff1a\u5f9e\u6240\u6709\u9375\u4e2d\u9078\u64c7\u6700\u5c11\u4f7f\u7528\u7684\u9375\u9032\u884c\u6dd8\u6c70\u3002<\/li>\n<li><strong>volatile-lru<\/strong>\uff1a\u50c5\u5f9e\u8a2d\u7f6e\u4e86\u904e\u671f\u6642\u9593\u7684\u9375\u4e2d\u9078\u64c7\u6700\u5c11\u4f7f\u7528\u7684\u9375\u9032\u884c\u6dd8\u6c70\u3002<\/li>\n<li><strong>allkeys-random<\/strong>\uff1a\u96a8\u6a5f\u9078\u64c7\u4e00\u500b\u9375\u9032\u884c\u6dd8\u6c70\u3002<\/li>\n<li><strong>volatile-random<\/strong>\uff1a\u96a8\u6a5f\u9078\u64c7\u4e00\u500b\u8a2d\u7f6e\u4e86\u904e\u671f\u6642\u9593\u7684\u9375\u9032\u884c\u6dd8\u6c70\u3002<\/li>\n<li><strong>volatile-ttl<\/strong>\uff1a\u6839\u64da\u904e\u671f\u6642\u9593\u9078\u64c7\u5373\u5c07\u904e\u671f\u7684\u9375\u9032\u884c\u6dd8\u6c70\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aeredis%e7%9a%84%e6%b7%98%e6%b1%b0%e7%ad%96%e7%95%a5-iukkFfpeJJ\">\u5982\u4f55\u914d\u7f6eRedis\u7684\u6dd8\u6c70\u7b56\u7565<\/h2>\n<p>\u8981\u914d\u7f6eRedis\u7684\u6dd8\u6c70\u7b56\u7565\uff0c\u53ef\u4ee5\u5728Redis\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u9032\u884c\u8a2d\u7f6e\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u793a\u4f8b\uff1a<\/p>\n<pre><code>\n# \u5728redis.conf\u4e2d\u8a2d\u7f6e\u6dd8\u6c70\u7b56\u7565\nmaxmemory 256mb\nmaxmemory-policy allkeys-lru\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u793a\u4f8b\u4e2d\uff0c\u6211\u5011\u5c07\u6700\u5927\u5167\u5b58\u9650\u5236\u8a2d\u7f6e\u70ba256MB\uff0c\u4e26\u9078\u64c7\u4e86\u201callkeys-lru\u201d\u4f5c\u70ba\u6dd8\u6c70\u7b56\u7565\u3002\u9019\u610f\u5473\u8457\u7576\u5167\u5b58\u4f7f\u7528\u9054\u5230\u4e0a\u9650\u6642\uff0cRedis\u5c07\u81ea\u52d5\u79fb\u9664\u6700\u5c11\u4f7f\u7528\u7684\u9375\u3002<\/p>\n<h2 id=\"%e5%af%a6%e7%8f%be%e9%ab%98%e6%95%88%e6%b7%98%e6%b1%b0%e7%9a%84%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-iukkFfpeJJ\">\u5be6\u73fe\u9ad8\u6548\u6dd8\u6c70\u7684\u6700\u4f73\u5be6\u8e10<\/h2>\n<p>\u70ba\u4e86\u5be6\u73fe\u9ad8\u6548\u7684\u5feb\u53d6\u6dd8\u6c70\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u8003\u616e\u4ee5\u4e0b\u5e7e\u500b\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<ul>\n<li><strong>\u5408\u7406\u8a2d\u7f6e\u5167\u5b58\u9650\u5236<\/strong>\uff1a\u6839\u64da\u61c9\u7528\u9700\u6c42\u8a2d\u7f6e\u5408\u9069\u7684\u5167\u5b58\u9650\u5236\uff0c\u4ee5\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u6dd8\u6c70\u3002<\/li>\n<li><strong>\u9078\u64c7\u5408\u9069\u7684\u6dd8\u6c70\u7b56\u7565<\/strong>\uff1a\u6839\u64da\u6578\u64da\u4f7f\u7528\u6a21\u5f0f\u9078\u64c7\u6700\u9069\u5408\u7684\u6dd8\u6c70\u7b56\u7565\u3002<\/li>\n<li><strong>\u76e3\u63a7\u5167\u5b58\u4f7f\u7528\u60c5\u6cc1<\/strong>\uff1a\u5b9a\u671f\u6aa2\u67e5Redis\u7684\u5167\u5b58\u4f7f\u7528\u60c5\u6cc1\uff0c\u53ca\u6642\u8abf\u6574\u914d\u7f6e\u3002<\/li>\n<li><strong>\u4f7f\u7528\u904e\u671f\u6642\u9593<\/strong>\uff1a\u5c0d\u4e0d\u518d\u9700\u8981\u7684\u6578\u64da\u8a2d\u7f6e\u904e\u671f\u6642\u9593\uff0c\u8b93Redis\u81ea\u52d5\u7ba1\u7406\u9019\u4e9b\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-iukkFfpeJJ\">\u7d50\u8ad6<\/h2>\n<p>Redis\u7684\u5feb\u53d6\u6dd8\u6c70\u6a5f\u5236\u70ba\u958b\u767c\u8005\u63d0\u4f9b\u4e86\u9748\u6d3b\u7684\u5167\u5b58\u7ba1\u7406\u9078\u64c7\uff0c\u80fd\u5920\u6709\u6548\u63d0\u5347\u61c9\u7528\u6027\u80fd\u3002\u901a\u904e\u5408\u7406\u914d\u7f6e\u548c\u9078\u64c7\u5408\u9069\u7684\u6dd8\u6c70\u7b56\u7565\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u78ba\u4fdd\u7cfb\u7d71\u5728\u9ad8\u8ca0\u8f09\u4e0b\u4f9d\u7136\u4fdd\u6301\u7a69\u5b9a\u904b\u884c\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u6548\u6578\u64da\u8655\u7406\u7684\u61c9\u7528\uff0cRedis\u7121\u7591\u662f\u4e00\u500b\u503c\u5f97\u8003\u616e\u7684\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc\u65bc<code>VPS<\/code>\u3001<code>\u9999\u6e2fVPS<\/code>\u53ca\u5176\u4ed6\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\u7684\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Redis\u5982\u4f55\u9ad8\u6548\u5be6\u73fe\u5feb\u53d6\u6dd8\u6c70\u7b56\u7565\uff0c\u63d0\u5347\u6027\u80fd\u8207\u8cc7\u6e90\u7ba1\u7406\uff0c\u78ba\u4fdd\u7cfb\u7d71\u7a69\u5b9a\u904b\u884c\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-128575","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/128575","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=128575"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/128575\/revisions"}],"predecessor-version":[{"id":128576,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/128575\/revisions\/128576"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=128575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=128575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=128575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}