{"id":60910,"date":"2023-05-08T15:05:56","date_gmt":"2023-05-08T07:05:56","guid":{"rendered":"http:\/\/www.idc.net\/help\/60910\/"},"modified":"2023-05-08T15:05:56","modified_gmt":"2023-05-08T07:05:56","slug":"redis%e9%80%9a%e4%bf%a1%e6%96%b9%e5%bc%8f%e5%ae%9e%e7%8e%b0%e9%ab%98%e6%80%a7%e8%83%bd%e9%80%9a%e4%bf%a1%ef%bc%88redis%e9%80%9a%e4%bf%a1%e6%96%b9%e5%bc%8f%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%89","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/60910\/","title":{"rendered":"Redis\u901a\u4fe1\u65b9\u5f0f\u5b9e\u73b0\u9ad8\u6027\u80fd\u901a\u4fe1\uff08redis\u901a\u4fe1\u65b9\u5f0f\u662f\u4ec0\u4e48\uff09"},"content":{"rendered":"<p>Redis\u662f\u76ee\u524d\u6d41\u884c\u3001\u9ad8\u6027\u80fd\u7684\u5206\u5e03\u5f0f\u5185\u5b58\u6570\u636e\u5e93\uff0c\u652f\u6301\u5355\u4e2a\u670d\u52a1\u5668\uff0c\u96c6\u7fa4\uff0c\u54e8\u5175\u6a21\u5f0f\u7b49\u6a21\u5f0f\uff0c\u80fd\u591f\u9ad8\u6548\u5730\u5b58\u53d6\u6570\u636e\uff0c\u4f7f\u7528\u6548\u7387\u6781\u9ad8\uff0c\u6210\u4e3a\u5404\u79cd\u5e94\u7528\u7684\u5171\u8bc6\u5b58\u50a8\u89e3\u51b3\u65b9\u6848\u3002Redis\u7684\u901a\u4fe1\u65b9\u5f0f\u4e5f\u662f\u6211\u4eec\u91cd\u70b9\u7814\u7a76\u7684\u90e8\u5206\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<p>Redis\u7684\u901a\u4fe1\u65b9\u5f0f\u4e3b\u8981\u6709\u4e24\u79cd\uff1aTCP\u901a\u4fe1\u548cUDP\u901a\u4fe1\u3002\u4e24\u8005\u90fd\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u6027\u80fd\u3001\u53ef\u9760\u7684\u6570\u636e\u901a\u4fe1\u3002<\/p>\n<\/p>\n<p>TCP\u901a\u4fe1\u662fTCP\/IP\u534f\u8bae\u6808\u4e2d\u5e38\u7528\u7684\u901a\u4fe1\u65b9\u5f0f\uff0c\u5b83\u53ef\u4ee5\u4fdd\u8bc1<\/p>\n<p>data\u662f50x\u7a33\u5b9a\uff0c\u9ad8\u901f\uff0c\u4e5f\u53ef\u4ee5\u63d0\u4f9b\u53ef\u9760\u7684\u6570\u636e\u4f20\u8f93\u3002Redis\u7684 TCP \u901a\u4fe1\u7ba1\u7406\u662f\u57fa\u4e8eTCP\u7684\uff0c\u6240\u4ee5\u5b83\u7684\u4f20\u8f93\u6548\u7387\u4e5f\u5f88\u9ad8\uff0c\u6570\u636e\u5b89\u5168\u53ef\u9760\u3002<\/p>\n<\/p>\n<p>UDP \u901a\u4fe1\u4e0e TCP \u901a\u4fe1\u4e0d\u540c\uff0cUDP \u662f\u4e00\u79cd\u4e0d\u53ef\u9760\u7684\u7f51\u7edc\u534f\u8bae\uff0cRedis\u6570\u636e\u7684\u4f20\u8f93\u4ec5\u4ec5\u9760UDP\u7684\u4e00\u6b21\u53d1\u9001\uff0c\u4e0d\u5b58\u5728\u591a\u6b21\u91cd\u53d1\uff0c\u6240\u4ee5UDP\u7684\u4f20\u8f93\u6548\u7387\u6bd4TCP\u9ad8\u5f97\u591a\uff0c\u5bf9\u6027\u80fd\u8981\u6c42\u975e\u5e38\u9ad8\u7684\u7f51\u7edc\u73af\u5883\u4e2d\uff0c\u901a\u5e38\u9996\u9009UDP \u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n<\/p>\n<p>Redis\u4e5f\u652f\u6301\u7f51\u7edc\u5e93socket\uff0c\u5b83\u5c06\u4f20\u8f93\u673a\u5236\u5c01\u88c5\u6210\u51fd\u6570\uff0c\u652f\u6301\u4e0d\u540c\u8bed\u8a00\u8c03\u7528\uff0c\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u8c03\u7528\u7f51\u7edc\u5e93\u76f8\u5173\u51fd\u6570\uff0c\u8ba9\u7a0b\u5e8f\u53ea\u9700\u8981\u8d1f\u8d23\u6267\u884c\u529f\u80fd\uff0c\u800c\u4e0d\u7528\u53bb\u7ba1\u7406\u7f51\u7edc\u5e93\u3002<\/p>\n<\/p>\n<p>\u4f8b\u5982\uff0c\u5728Node.js\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u8fde\u63a5Redis\u670d\u52a1\uff1a<\/p>\n<pre>const redis = require('redis');<br>let conn = redis.createClient(6379, '127.0.0.1');<br><br>conn.on('connect', () =&gt; {<br>  console.log('Redis\u8fde\u63a5\u6210\u529f');<br>});<br><\/pre>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fRedis\u7f51\u7edc\u901a\u4fe1\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0cRedis\u7684 TCP\/UDP \u548c socket \u7b49\u534f\u8bae\u53ef\u4ee5\u6ee1\u8db3\u5404\u79cd\u4e0d\u540c\u6027\u80fd\u9700\u6c42\uff0c\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u7684\u7de9\u5b58\u670d\u52a1\u9ad8\u6548\u6301\u4e45\u53ef\u9760\u3002<\/p>\n<p><a href=\"http:https:\/\/idc.net\/\">\u9999\u6e2f\u670d\u52a1\u5668<\/a>\u9996\u9009\u540e\u6d6a\u4e91\uff0c2H2G\u9996\u670810\u5143\u5f00\u901a\u3002<br \/>\u540e\u6d6a\u4e91\uff08www.IDC.Net\uff09\u63d0\u4f9b\u7b80\u5355\u597d\u7528\uff0c\u4ef7\u683c\u539a\u9053\u7684\u9999\u6e2f\/\u7f8e\u56fd\u4e91\u670d\u52a1\u5668\u548c\u72ec\u7acb\u670d\u52a1\u5668\u3002IDC+ISP+ICP\u8d44\u8d28\u3002ARIN\u548cAPNIC\u4f1a\u5458\u3002\u6210\u719f\u6280\u672f\u56e2\u961f15\u5e74\u884c\u4e1a\u7ecf\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis\u662f\u76ee\u524d\u6d41\u884c\u3001\u9ad8\u6027\u80fd\u7684\u5206\u5e03\u5f0f\u5185\u5b58\u6570\u636e\u5e93\uff0c\u652f\u6301\u5355\u4e2a\u670d\u52a1\u5668\uff0c\u96c6\u7fa4\uff0c\u54e8\u5175\u6a21\u5f0f\u7b49\u6a21\u5f0f\uff0c\u80fd\u591f\u9ad8\u6548\u5730\u5b58\u53d6\u6570\u636e\uff0c\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7038],"tags":[],"class_list":["post-60910","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/60910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=60910"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/60910\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=60910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=60910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=60910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}