{"id":129665,"date":"2024-10-26T23:25:19","date_gmt":"2024-10-26T15:25:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/129665\/"},"modified":"2024-10-26T23:25:20","modified_gmt":"2024-10-26T15:25:20","slug":"redis%e7%b6%b2%e7%b5%a1%e6%b5%81%e9%87%8f%e5%88%86%e6%9e%90%e5%be%9e%e6%95%b8%e6%93%9a%e6%b5%81%e4%b8%ad%e7%99%bc%e7%8f%be%e6%bd%9b%e5%9c%a8%e5%83%b9%e5%80%bc%ef%bc%88redis%e7%b6%b2%e7%b5%a1%e6%b5%81","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/129665\/","title":{"rendered":"Redis\u7db2\u7d61\u6d41\u91cf\u5206\u6790\u5f9e\u6578\u64da\u6d41\u4e2d\u767c\u73fe\u6f5b\u5728\u50f9\u503c\uff08redis\u7db2\u7d61\u6d41\u91cf\u5206\u6790\uff09"},"content":{"rendered":"<h1 id=\"redis%e7%b6%b2%e7%b5%a1%e6%b5%81%e9%87%8f%e5%88%86%e6%9e%90%e5%be%9e%e6%95%b8%e6%93%9a%e6%b5%81%e4%b8%ad%e7%99%bc%e7%8f%be%e6%bd%9b%e5%9c%a8%e5%83%b9%e5%80%bc-PWUqqtyLmm\">Redis\u7db2\u7d61\u6d41\u91cf\u5206\u6790\u5f9e\u6578\u64da\u6d41\u4e2d\u767c\u73fe\u6f5b\u5728\u50f9\u503c<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u4f01\u696d\u8d8a\u4f86\u8d8a\u4f9d\u8cf4\u65bc\u6578\u64da\u5206\u6790\u4f86\u63d0\u5347\u696d\u52d9\u6548\u7387\u548c\u6c7a\u7b56\u80fd\u529b\u3002Redis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u6578\u64da\u7d50\u69cb\u5b58\u5132\u7cfb\u7d71\uff0c\u4e0d\u50c5\u80fd\u5920\u5feb\u901f\u5b58\u53d6\u6578\u64da\uff0c\u9084\u80fd\u5728\u7db2\u7d61\u6d41\u91cf\u5206\u6790\u4e2d\u767c\u63ee\u91cd\u8981\u4f5c\u7528\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5229\u7528Redis\u9032\u884c\u7db2\u7d61\u6d41\u91cf\u5206\u6790\uff0c\u4e26\u5f9e\u4e2d\u6316\u6398\u6f5b\u5728\u7684\u5546\u696d\u50f9\u503c\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afredis%ef%bc%9f-PWUqqtyLmm\">\u4ec0\u9ebc\u662fRedis\uff1f<\/h2>\n<p>Redis\uff08Remote Dictionary Server\uff09\u662f\u4e00\u7a2e\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\u7b49\u3002\u7531\u65bc\u5176\u9ad8\u6548\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\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=\"%e7%b6%b2%e7%b5%a1%e6%b5%81%e9%87%8f%e5%88%86%e6%9e%90%e7%9a%84%e5%bf%85%e8%a6%81%e6%80%a7-PWUqqtyLmm\">\u7db2\u7d61\u6d41\u91cf\u5206\u6790\u7684\u5fc5\u8981\u6027<\/h2>\n<p>\u96a8\u8457\u4e92\u806f\u7db2\u7684\u767c\u5c55\uff0c\u4f01\u696d\u9762\u81e8\u8457\u5927\u91cf\u7684\u7db2\u7d61\u6d41\u91cf\u6578\u64da\u3002\u9019\u4e9b\u6578\u64da\u5305\u542b\u4e86\u7528\u6236\u884c\u70ba\u3001\u4ea4\u6613\u8a18\u9304\u548c\u7cfb\u7d71\u6027\u80fd\u7b49\u4fe1\u606f\u3002\u901a\u904e\u5c0d\u9019\u4e9b\u6578\u64da\u7684\u5206\u6790\uff0c\u4f01\u696d\u53ef\u4ee5\u7372\u5f97\u4ee5\u4e0b\u5e7e\u500b\u65b9\u9762\u7684\u50f9\u503c\uff1a<\/p>\n<ul>\n<li><strong>\u7528\u6236\u884c\u70ba\u5206\u6790\uff1a<\/strong>\u4e86\u89e3\u7528\u6236\u7684\u8a2a\u554f\u6a21\u5f0f\u548c\u504f\u597d\uff0c\u5f9e\u800c\u512a\u5316\u7522\u54c1\u548c\u670d\u52d9\u3002<\/li>\n<li><strong>\u6027\u80fd\u76e3\u63a7\uff1a<\/strong>\u53ca\u6642\u767c\u73fe\u7cfb\u7d71\u74f6\u9838\uff0c\u63d0\u5347\u670d\u52d9\u7a69\u5b9a\u6027\u3002<\/li>\n<li><strong>\u5b89\u5168\u6027\u6aa2\u6e2c\uff1a<\/strong>\u8b58\u5225\u7570\u5e38\u6d41\u91cf\uff0c\u9632\u7bc4\u6f5b\u5728\u7684\u5b89\u5168\u5a01\u8105\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8redis%e9%80%b2%e8%a1%8c%e7%b6%b2%e7%b5%a1%e6%b5%81%e9%87%8f%e5%88%86%e6%9e%90-PWUqqtyLmm\">\u5982\u4f55\u4f7f\u7528Redis\u9032\u884c\u7db2\u7d61\u6d41\u91cf\u5206\u6790<\/h2>\n<p>\u4f7f\u7528Redis\u9032\u884c\u7db2\u7d61\u6d41\u91cf\u5206\u6790\u7684\u904e\u7a0b\u53ef\u4ee5\u5206\u70ba\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e6%95%b8%e6%93%9a%e6%94%b6%e9%9b%86-PWUqqtyLmm\">1. \u6578\u64da\u6536\u96c6<\/h3>\n<p>\u9996\u5148\uff0c\u9700\u8981\u6536\u96c6\u7db2\u7d61\u6d41\u91cf\u6578\u64da\u3002\u9019\u53ef\u4ee5\u901a\u904e\u5404\u7a2e\u65b9\u5f0f\u5be6\u73fe\uff0c\u4f8b\u5982\u4f7f\u7528\u7db2\u7d61\u76e3\u63a7\u5de5\u5177\u6216\u81ea\u5b9a\u7fa9\u7684\u6578\u64da\u6536\u96c6\u8173\u672c\u3002\u6536\u96c6\u5230\u7684\u6578\u64da\u53ef\u4ee5\u5305\u62ec\u7528\u6236IP\u5730\u5740\u3001\u8a2a\u554f\u6642\u9593\u3001\u8acb\u6c42URL\u7b49\u4fe1\u606f\u3002<\/p>\n<h3 id=\"2-%e6%95%b8%e6%93%9a%e5%ad%98%e5%84%b2-PWUqqtyLmm\">2. \u6578\u64da\u5b58\u5132<\/h3>\n<p>\u5c07\u6536\u96c6\u5230\u7684\u6578\u64da\u5b58\u5132\u5230Redis\u4e2d\u3002\u53ef\u4ee5\u4f7f\u7528Redis\u7684\u54c8\u5e0c\u7d50\u69cb\u4f86\u5b58\u5132\u6bcf\u500b\u8acb\u6c42\u7684\u8a73\u7d30\u4fe1\u606f\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>HMSET request:1 ip \"192.168.1.1\" timestamp \"2023-10-01T12:00:00Z\" url \"\/home\"<\/code><\/pre>\n<h3 id=\"3-%e6%95%b8%e6%93%9a%e5%88%86%e6%9e%90-PWUqqtyLmm\">3. \u6578\u64da\u5206\u6790<\/h3>\n<p>\u5229\u7528Redis\u7684\u6578\u64da\u7d50\u69cb\u548c\u547d\u4ee4\u9032\u884c\u6578\u64da\u5206\u6790\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528Redis\u7684\u8a08\u6578\u5668\u4f86\u7d71\u8a08\u6bcf\u500bURL\u7684\u8a2a\u554f\u6b21\u6578\uff1a<\/p>\n<pre><code>INCR url:home:count<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u5feb\u901f\u7372\u5f97\u67d0\u500b\u9801\u9762\u7684\u8a2a\u554f\u91cf\uff0c\u5e6b\u52a9\u4f01\u696d\u4e86\u89e3\u7528\u6236\u7684\u8208\u8da3\u6240\u5728\u3002<\/p>\n<h3 id=\"4-%e5%8f%af%e8%a6%96%e5%8c%96%e5%b1%95%e7%a4%ba-PWUqqtyLmm\">4. \u53ef\u8996\u5316\u5c55\u793a<\/h3>\n<p>\u5c07\u5206\u6790\u7d50\u679c\u9032\u884c\u53ef\u8996\u5316\u5c55\u793a\uff0c\u5e6b\u52a9\u6c7a\u7b56\u8005\u66f4\u76f4\u89c0\u5730\u7406\u89e3\u6578\u64da\u3002\u53ef\u4ee5\u4f7f\u7528\u5404\u7a2e\u53ef\u8996\u5316\u5de5\u5177\uff0c\u5982Grafana\u6216Tableau\uff0c\u5c07Redis\u4e2d\u7684\u6578\u64da\u8f49\u63db\u70ba\u5716\u8868\u6216\u5100\u8868\u677f\u3002<\/p>\n<h2 id=\"%e6%a1%88%e4%be%8b%e5%88%86%e6%9e%90-PWUqqtyLmm\">\u6848\u4f8b\u5206\u6790<\/h2>\n<p>\u5047\u8a2d\u4e00\u5bb6\u96fb\u5b50\u5546\u52d9\u7db2\u7ad9\u5e0c\u671b\u5206\u6790\u5176\u6d41\u91cf\u6578\u64da\u4ee5\u63d0\u5347\u92b7\u552e\u3002\u901a\u904e\u4f7f\u7528Redis\uff0c\u4ed6\u5011\u53ef\u4ee5\u5be6\u6642\u8ddf\u8e64\u6bcf\u500b\u7522\u54c1\u9801\u9762\u7684\u8a2a\u554f\u91cf\uff0c\u4e26\u6839\u64da\u6578\u64da\u8abf\u6574\u71df\u92b7\u7b56\u7565\u3002\u4f8b\u5982\uff0c\u82e5\u67d0\u7522\u54c1\u9801\u9762\u5728\u7279\u5b9a\u6642\u9593\u6bb5\u5167\u7684\u8a2a\u554f\u91cf\u6fc0\u589e\uff0c\u4f01\u696d\u53ef\u4ee5\u8003\u616e\u63a8\u51fa\u9650\u6642\u512a\u60e0\u4ee5\u4fc3\u9032\u92b7\u552e\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-PWUqqtyLmm\">\u7d50\u8ad6<\/h2>\n<p>Redis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u70ba\u7db2\u7d61\u6d41\u91cf\u5206\u6790\u63d0\u4f9b\u4e86\u5f37\u5927\u7684\u652f\u6301\u3002\u901a\u904e\u5408\u7406\u7684\u6578\u64da\u6536\u96c6\u3001\u5b58\u5132\u548c\u5206\u6790\uff0c\u4f01\u696d\u80fd\u5920\u5f9e\u6d77\u91cf\u7684\u6578\u64da\u6d41\u4e2d\u6316\u6398\u51fa\u6f5b\u5728\u7684\u5546\u696d\u50f9\u503c\uff0c\u5f9e\u800c\u63d0\u5347\u696d\u52d9\u6548\u7387\u548c\u7af6\u722d\u529b\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u5982\u4f55\u5229\u7528Redis\u9032\u884c\u6578\u64da\u5206\u6790\u7684\u8cc7\u8a0a\uff0c\u6216\u5c0b\u627e\u5408\u9069\u7684<a href=\"https:\/\/server.hk\">VPS<\/a>\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Redis\u7db2\u7d61\u6d41\u91cf\u5206\u6790\uff0c\u5f9e\u6578\u64da\u6d41\u4e2d\u6316\u6398\u6f5b\u5728\u50f9\u503c\uff0c\u63d0\u5347\u696d\u52d9\u6c7a\u7b56\u8207\u6027\u80fd\u512a\u5316\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-129665","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/129665","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=129665"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/129665\/revisions"}],"predecessor-version":[{"id":129666,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/129665\/revisions\/129666"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=129665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=129665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=129665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}