{"id":201496,"date":"2025-05-10T12:04:31","date_gmt":"2025-05-10T04:04:31","guid":{"rendered":"https:\/\/server.hk\/cnblog\/201496\/"},"modified":"2025-05-10T12:04:31","modified_gmt":"2025-05-10T04:04:31","slug":"redis%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97%e5%8f%91%e5%b1%95%e5%8e%86%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/201496\/","title":{"rendered":"Redis\u6d88\u606f\u961f\u5217\u53d1\u5c55\u5386\u7a0b"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Redis\u6d88\u606f\u961f\u5217\u53d1\u5c55\u5386\u7a0b<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5728\u6570\u636e\u5e93\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929golang\u5b66\u4e60\u7f51\u5c31\u6574\u7406\u5206\u4eab\u300aRedis\u6d88\u606f\u961f\u5217\u53d1\u5c55\u5386\u7a0b\u300b\uff0c\u804a\u804aRedis\u3001\u6d88\u606f\u961f\u5217\u3001\u6570\u636e\u5e93\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002<\/p>\n<p>\u4f5c\u8005 |&nbsp;\u4e15\u5929<\/p>\n<p>Redis\u662f\u76ee\u524d\u6700\u53d7\u6b22\u8fce\u7684kv\u7c7b\u6570\u636e\u5e93\uff0c\u5f53\u7136\u5b83\u7684\u529f\u80fd\u8d8a\u6765\u8d8a\u591a\uff0c\u65e9\u5df2\u4e0d\u9650\u5b9a\u5728kv\u573a\u666f\uff0c\u6d88\u606f\u961f\u5217\u5c31\u662fRedis\u4e2d\u4e00\u4e2a\u91cd\u8981\u7684\u529f\u80fd\u3002<\/p>\n<p>Redis\u4ece2010\u5e74\u53d1\u5e031.0\u7248\u672c\u5c31\u5177\u5907\u4e00\u4e2a\u6d88\u606f\u961f\u5217\u7684\u96cf\u5f62\uff0c\u968f\u774010\u591a\u5e74\u7684\u8fed\u4ee3\uff0c\u5176\u6d88\u606f\u961f\u5217\u7684\u529f\u80fd\u4e5f\u8d8a\u6765\u8d8a\u5b8c\u5584\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u5168\u5185\u5b58\u7684\u6d88\u606f\u961f\u5217\uff0c\u9002\u5408\u5e94\u7528\u4e0e\u8981\u6c42\u9ad8\u541e\u5410\u3001\u4f4e\u5ef6\u65f6\u7684\u573a\u666f\u3002<\/p>\n<p>\u6211\u4eec\u6765\u76d8\u4e00\u4e0bRedis\u6d88\u606f\u961f\u5217\u529f\u80fd\u7684\u53d1\u5c55\u5386\u7a0b\uff0c\u5386\u53f2\u7248\u672c\u6709\u54ea\u4e9b\u4e0d\u8db3\uff0c\u540e\u7eed\u7248\u672c\u662f\u5982\u4f55\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u7684\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342063eddeac9b519.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h3>\u4e00\u3001Redis 1.0 list<\/h3>\n<p>\u4ece\u5e7f\u4e49\u4e0a\u6765\u8bb2\u6d88\u606f\u961f\u5217\u5c31\u662f\u4e00\u4e2a\u961f\u5217\u7684\u6570\u636e\u7ed3\u6784\uff0c\u751f\u4ea7\u8005\u4ece\u961f\u5217\u4e00\u7aef\u653e\u5165\u6d88\u606f\uff0c\u6d88\u8d39\u8005\u4ece\u53e6\u4e00\u7aef\u8bfb\u53d6\u6d88\u606f\uff0c\u6d88\u606f\u4fdd\u8bc1\u5148\u5165\u5148\u51fa\u7684\u987a\u5e8f\uff0c\u4e00\u4e2a\u672c\u5730\u7684list\u6570\u636e\u7ed3\u6784\u5c31\u662f\u4e00\u4e2a\u8fdb\u7a0b\u7ef4\u5ea6\u7684\u6d88\u606f\u961f\u5217\uff0c\u5b83\u53ef\u4ee5\u8ba9\u6a21\u5757A\u5199\u5165\u6d88\u606f\uff0c\u6a21\u5757B\u6d88\u8d39\u6d88\u606f\uff0c\u505a\u5230\u6a21\u5757A\/B\u7684\u89e3\u8026\u4e0e\u5f02\u6b65\u5316\u3002\u4f46\u60f3\u8981\u505a\u5230\u5e94\u7528\u7ea7\u522b\u7684\u89e3\u8026\u548c\u5f02\u6b65\u8fd8\u9700\u8981\u4e00\u4e2a\u6d88\u606f\u961f\u5217\u7684\u670d\u52a1\u3002<\/p>\n<h4>1.list\u7684\u7279\u6027<\/h4>\n<p>Redis 1.0\u53d1\u5e03\u65f6\u5c31\u5177\u5907\u4e86list\u6570\u636e\u7ed3\u6784\uff0c\u5e94\u7528A\u53ef\u4ee5\u901a\u8fc7lpush\u5199\u5165\u6d88\u606f\uff0c\u5e94\u7528B\u901a\u8fc7rpop\u4ece\u961f\u5217\u4e2d\u8bfb\u53d6\u6d88\u606f\uff0c\u6bcf\u4e2a\u6d88\u606f\u53ea\u4f1a\u88ab\u8bfb\u53d6\u4e00\u6b21\uff0c\u800c\u4e14\u662f\u6309\u7167lpush\u5199\u5165\u7684\u987a\u5e8f\u8bfb\u5230\u3002\u540c\u65f6Redis\u7684\u63a5\u53e3\u662f\u5e76\u53d1\u5b89\u5168\u7684\uff0c\u53ef\u4ee5\u540c\u65f6\u6709\u591a\u4e2a\u751f\u4ea7\u8005\u5411\u4e00\u4e2alist\u4e2d\u751f\u4ea7\u6d88\u606f\uff0c\u591a\u4e2a\u6d88\u8d39\u8005\u4ecelist\u4e2d\u8bfb\u53d6\u6d88\u606f\u3002<\/p>\n<p>\u8fd9\u91cc\u8fd8\u6709\u4e2a\u95ee\u9898\uff0c\u6d88\u8d39\u8005\u8981\u5982\u4f55\u77e5\u9053list\u4e2d\u6709\u6d88\u606f\u4e86\uff0c\u9700\u8981\u4e0d\u65ad\u8f6e\u8be2\u53bb\u67e5\u8be2\u5417\u3002\u8f6e\u8be2\u65e0\u6cd5\u4fdd\u8bc1\u6d88\u606f\u88ab\u53ca\u65f6\u7684\u5904\u7406\uff0c\u4f1a\u589e\u52a0\u5ef6\u65f6\uff0c\u800c\u4e14\u5f53list\u4e3a\u7a7a\u65f6\uff0c\u5927\u90e8\u5206\u8f6e\u8be2\u7684\u8bf7\u6c42\u90fd\u662f\u65e0\u6548\u8bf7\u6c42\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5927\u91cf\u6d6a\u8d39\u4e86\u7cfb\u7edf\u8d44\u6e90\u3002\u597d\u5728Redis\u6709brpop\u63a5\u53e3\uff0c\u8be5\u63a5\u53e3\u6709\u4e00\u4e2a\u53c2\u6570\u662f\u8d85\u65f6\u65f6\u95f4\uff0c\u5982\u679clist\u4e3a\u7a7a\uff0c\u90a3\u4e48Redis\u670d\u52a1\u7aef\u4e0d\u4f1a\u7acb\u523b\u8fd4\u56de\u7ed3\u679c\uff0c\u5b83\u4f1a\u7b49\u5f85list\u4e2d\u6709\u65b0\u6570\u636e\u540e\u5728\u8fd4\u56de\u6216\u662f\u7b49\u5f85\u6700\u591a\u4e00\u4e2a\u8d85\u65f6\u65f6\u95f4\u540e\u8fd4\u56de\u7a7a\u3002\u901a\u8fc7brpop\u63a5\u53e3\u5b9e\u73b0\u4e86\u957f\u8f6e\u8be2\uff0c\u8be5\u6548\u679c\u7b49\u540c\u4e8e\u670d\u52a1\u7aef\u63a8\u9001\uff0c\u6d88\u8d39\u8005\u80fd\u7acb\u523b\u611f\u77e5\u5230\u65b0\u7684\u6d88\u606f\uff0c\u800c\u4e14\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684\u8d85\u65f6\u65f6\u95f4\uff0c\u4f7f\u7cfb\u7edf\u8d44\u6e90\u7684\u6d88\u8017\u964d\u5230\u5f88\u4f4e\u3002<\/p>\n<p>#\u57fa\u4e8elist\u5b8c\u6210\u6d88\u606f\u7684\u751f\u4ea7\u548c\u6d88\u8d39<\/p>\n<p>#\u751f\u4ea7\u8005\u751f\u4ea7\u6d88\u606fmsg1<br \/>lpush listA msg1<br \/><span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><\/p>\n<p>#\u6d88\u8d39\u8005\u8bfb\u53d6\u5230\u6d88\u606fmsg1<br \/>rpop listA<br \/><span style=\"margin: 0px;padding: 0px\">&#8220;msg1&#8221;<\/span><\/p>\n<p>#\u6d88\u8d39\u8005\u963b\u585e\u5f0f\u8bfb\u53d6listA\uff0c\u5982\u679c\u6709\u6570\u636e\u7acb\u523b\u8fd4\u56de\uff0c\u5426\u5219\u6700\u591a\u7b49\u5f8510\u79d2<br \/>brpop listA <span style=\"margin: 0px;padding: 0px\">10<\/span> <br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;listA&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;msg1&#8221;<\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342163eddead178c4.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p>\u4f7f\u7528rpop\u6216brpop\u8fd9\u6837\u63a5\u53e3\u6d88\u8d39\u6d88\u606f\u4f1a\u5148\u4ece\u961f\u5217\u4e2d\u5220\u9664\u6d88\u606f\uff0c\u7136\u540e\u518d\u7531\u5e94\u7528\u6d88\u8d39\uff0c\u5982\u679c\u5e94\u7528\u5e94\u7528\u5728\u5904\u7406\u6d88\u606f\u524d\u5f02\u5e38\u5b95\u673a\u4e86\uff0c\u6d88\u606f\u5c31\u4e22\u5931\u4e86\u3002\u4f46\u5982\u679c\u4f7f\u7528lindex\u8fd9\u6837\u7684\u53ea\u8bfb\u547d\u4ee4\u5148\u8bfb\u53d6\u6d88\u606f\u5904\u7406\u5b8c\u6bd5\u540e\u5728\u5220\u9664\uff0c\u53c8\u9700\u8981\u989d\u5916\u7684\u673a\u5236\u6765\u4fdd\u8bc1\u4e00\u6761\u6d88\u606f\u4e0d\u4f1a\u88ab\u5176\u4ed6\u6d88\u8d39\u8005\u91cd\u590d\u8bfb\u5230\u3002\u597d\u5728list\u6709rpoplpush\u6216brpoplpush\u8fd9\u6837\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u539f\u5b50\u6027\u7684\u4ece\u4e00\u4e2alist\u4e2d\u79fb\u9664\u4e00\u4e2a\u6d88\u606f\u5e76\u52a0\u5165\u53e6\u4e00\u4e2alist\u3002<\/p>\n<p>\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc72\u4e2alist\u7ec4\u548c\u6765\u5b8c\u6210\u6d88\u606f\u7684\u6d88\u8d39\u548c\u786e\u8ba4\u529f\u80fd\uff0c\u4f7f\u7528rpoplpush\u4ecelist A\u4e2d\u6d88\u8d39\u6d88\u606f\u5e76\u79fb\u5165list B\uff0c\u7b49\u6d88\u606f\u5904\u7406\u5b8c\u6bd5\u540e\u5728\u4ecelist B\u4e2d\u5220\u9664\u6d88\u606f\uff0c\u5982\u679c\u5728\u5904\u7406\u6d88\u606f\u8fc7\u7a0b\u4e2d\u5e94\u7528\u5f02\u5e38\u5b95\u673a\uff0c\u6062\u590d\u540e\u5e94\u7528\u53ef\u4ee5\u91cd\u65b0\u4ecelist B\u4e2d\u8bfb\u53d6\u672a\u5904\u7406\u7684\u6d88\u606f\u5e76\u5904\u7406\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e3a\u6d88\u606f\u7684\u6d88\u8d39\u589e\u52a0\u4e86ack\u673a\u5236\u3002<\/p>\n<p>#\u57fa\u4e8e2\u4e2alist\u5b8c\u6210\u6d88\u606f\u6d88\u8d39\u548c\u786e\u8ba4<\/p>\n<p>#\u4ecelistA\u4e2d\u8bfb\u53d6\u6d88\u606f\u5e76\u5199\u5165listB<br \/>rpoplpush listA listB<br \/><span style=\"margin: 0px;padding: 0px\">&#8220;msg1&#8221;<\/span><\/p>\n<p>#\u4e1a\u52a1\u903b\u8f91\u5904\u7406msg1\u5b8c\u6bd5\u540e\uff0c\u4ecelistB\u4e2d\u5220\u9664msg1\uff0c\u5b8c\u6210\u6d88\u606f\u7684\u786e\u8ba4<br \/>lrem listB <span style=\"margin: 0px;padding: 0px\">1<\/span> msg1<br \/><span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342163eddead8c5d1.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h4>2.list\u7684\u4e0d\u8db3\u4e4b\u5904<\/h4>\n<p>\u901a\u8fc7Redis 1.0\u5c31\u5f15\u5165\u7684list\u7ed3\u6784\u6211\u4eec\u5c31\u80fd\u5b9e\u73b0\u4e00\u4e2a\u5206\u5e03\u5f0f\u7684\u6d88\u606f\u961f\u5217\uff0c\u6ee1\u8db3\u4e00\u4e9b\u7b80\u5355\u7684\u4e1a\u52a1\u9700\u6c42\u3002\u4f46list\u7ed3\u6784\u4f5c\u4e3a\u6d88\u606f\u961f\u5217\u670d\u52a1\u6709\u4e00\u4e2a\u5f88\u81f4\u547d\u7684\u95ee\u9898\uff0c\u5b83\u6ca1\u6709\u5e7f\u64ad\u529f\u80fd\uff0c\u4e00\u4e2a\u6d88\u606f\u53ea\u80fd\u88ab\u6d88\u8d39\u4e00\u6b21\u3002\u800c\u5728\u5927\u578b\u7cfb\u7edf\u4e2d\uff0c\u901a\u5e38\u4e00\u4e2a\u6d88\u606f\u4f1a\u88ab\u4e0b\u6e38\u591a\u4e2a\u5e94\u7528\u540c\u65f6\u8ba2\u9605\u548c\u6d88\u8d39\uff0c\u4f8b\u5982\u5f53\u7528\u6237\u5b8c\u6210\u4e00\u4e2a\u8ba2\u5355\u7684\u652f\u4ed8\u64cd\u4f5c\u65f6\uff0c\u9700\u8981\u901a\u77e5\u5546\u5bb6\u53d1\u8d27\uff0c\u8981\u66f4\u65b0\u7269\u6d41\u72b6\u6001\uff0c\u53ef\u80fd\u8fd8\u4f1a\u63d0\u9ad8\u7528\u6237\u7684\u79ef\u5206\u548c\u7b49\u7ea7\uff0c\u8fd9\u4e9b\u90fd\u662f\u4e0d\u540c\u7684\u4e0b\u6e38\u5b50\u7cfb\u7edf\uff0c\u4ed6\u4eec\u5168\u90e8\u4f1a\u8ba2\u9605\u652f\u4ed8\u5b8c\u6210\u7684\u64cd\u4f5c\uff0c\u800clist\u4e00\u4e2a\u6d88\u606f\u53ea\u80fd\u88ab\u6d88\u8d39\u4e00\u6b21\u5728\u8fd9\u6837\u590d\u6742\u7684\u5927\u578b\u7cfb\u7edf\u9762\u524d\u5c31\u6349\u895f\u89c1\u8098\u4e86\u3002<\/p>\n<p>\u53ef\u80fd\u4f60\u4f1a\u8bf4\u90a3\u5f04\u591a\u4e2alist\uff0c\u751f\u4ea7\u8005\u5411\u6bcf\u4e2alist\u4e2d\u90fd\u6295\u9012\u6d88\u606f\uff0c\u6bcf\u4e2a\u6d88\u8d39\u8005\u5904\u7406\u81ea\u5df1\u7684list\u4e0d\u5c31\u884c\u4e86\u5417\u3002\u8fd9\u6837\u7b2c\u4e00\u662f\u6027\u80fd\u4e0d\u4f1a\u592a\u597d\uff0c\u56e0\u4e3a\u540c\u4e00\u4e2a\u6d88\u606f\u9700\u8981\u88ab\u91cd\u590d\u7684\u6295\u9012\uff0c\u7b2c\u4e8c\u662f\u8fd9\u6837\u7684\u8bbe\u8ba1\u8fdd\u53cd\u4e86\u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005\u89e3\u8026\u7684\u539f\u5219\uff0c\u8fd9\u4e2a\u8bbe\u8ba1\u4e0b\u751f\u4ea7\u8005\u9700\u8981\u77e5\u9053\u4e0b\u6e38\u6709\u54ea\u4e9b\u6d88\u8d39\u8005\uff0c\u5982\u679c\u4e1a\u52a1\u53d1\u751f\u53d8\u5316\uff0c\u9700\u8981\u989d\u5916\u589e\u52a0\u4e00\u4e2a\u6d88\u8d39\u8005\uff0c\u751f\u4ea7\u8005\u7684\u4ee3\u7801\u4e5f\u9700\u8981\u4fee\u6539\u3002<\/p>\n<h4>3.\u603b\u7ed3<\/h4>\n<p><strong>\u4f18\u52bf<\/strong><\/p>\n<p>\u6a21\u578b\u7b80\u5355\uff0c\u548c\u4f7f\u7528\u672c\u5730list\u57fa\u672c\u76f8\u540c\uff0c\u9002\u914d\u5bb9\u6613<\/p>\n<p>\u901a\u8fc7brpop\u505a\u5230\u6d88\u606f\u5904\u7406\u7684\u5b9e\u65f6\u6027<\/p>\n<p>\u901a\u8fc7rpoplpush\u6765\u8054\u52a82\u4e2alist\uff0c\u53ef\u4ee5\u505a\u5230\u6d88\u606f\u5148\u6d88\u8d39\u540e\u786e\u8ba4\uff0c\u907f\u514d\u6d88\u8d39\u8005\u5e94\u7528\u5f02\u5e38\u60c5\u51b5\u4e0b\u6d88\u606f\u4e22\u5931<\/p>\n<p><strong>\u4e0d\u8db3<\/strong><\/p>\n<p>\u6d88\u606f\u53ea\u80fd\u88ab\u6d88\u8d39\u4e00\u6b21\uff0c\u7f3a\u4e4f\u5e7f\u64ad\u673a\u5236<\/p>\n<h3>\u4e8c\u3001Redis 2.0 pubsub<\/h3>\n<p>list\u4f5c\u4e3a\u6d88\u606f\u961f\u5217\u5e94\u7528\u573a\u666f\u53d7\u5230\u9650\u5236\u5f88\u91cd\u8981\u7684\u539f\u56e0\u5728\u4e8e\u6ca1\u6709\u5e7f\u64ad\uff0c\u6240\u4ee5Redis 2.0\u4e2d\u5f15\u5165\u4e86\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u7ed3\u6784pubsub\u3002pubsub\u867d\u7136\u4e0d\u80fd\u7b97\u4f5c\u662flist\u7684\u66ff\u4ee3\u54c1\uff0c\u4f46\u5b83\u786e\u5b9e\u80fd\u89e3\u51b3\u4e00\u4e9blist\u4e0d\u80fd\u89e3\u51b3\u7684\u95ee\u9898\u3002<\/p>\n<h4>1.pubsub\u7279\u6027<\/h4>\n<p>pubsub\u5f15\u5165\u4e00\u4e2a\u6982\u5ff5\u53ebchannel\uff0c\u751f\u4ea7\u8005\u901a\u8fc7publish\u63a5\u53e3\u6295\u9012\u6d88\u606f\u65f6\u4f1a\u6307\u5b9achannel\uff0c\u6d88\u8d39\u8005\u901a\u8fc7subscribe\u63a5\u53e3\u8ba2\u9605\u5b83\u5173\u5fc3\u7684channel\uff0c\u8c03\u7528subscribe\u540e\u8fd9\u6761\u8fde\u63a5\u4f1a\u8fdb\u5165\u4e00\u4e2a\u7279\u6b8a\u7684\u72b6\u6001\uff0c\u901a\u5e38\u4e0d\u80fd\u5728\u53d1\u9001\u5176\u4ed6\u8bf7\u6c42\uff0c\u5f53\u6709\u6d88\u606f\u6295\u9012\u5230\u8fd9\u4e2achannel\u65f6Redis\u670d\u52a1\u7aef\u4f1a\u7acb\u523b\u901a\u8fc7\u8be5\u8fde\u63a5\u5c06\u6d88\u606f\u63a8\u9001\u5230\u6d88\u8d39\u8005\u3002\u8fd9\u91cc\u4e00\u4e2achannel\u53ef\u4ee5\u88ab\u591a\u4e2a\u5e94\u7528\u8ba2\u9605\uff0c\u6d88\u606f\u4f1a\u540c\u65f6\u6295\u9012\u5230\u6bcf\u4e2a\u8ba2\u9605\u8005\uff0c\u505a\u5230\u4e86\u6d88\u606f\u7684\u5e7f\u64ad\u3002<\/p>\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u6d88\u8d39\u8005\u53ef\u4ee5\u4f1a\u8ba2\u9605\u4e00\u6279channel\uff0c\u4f8b\u5982\u4e00\u4e2a\u7528\u6237\u8ba2\u9605\u4e86\u6d59\u6c5f\u7684\u65b0\u95fb\u7684\u63a8\u9001\uff0c\u4f46\u6d59\u6c5f\u65b0\u95fb\u8fd8\u4f1a\u8fdb\u884c\u7ec6\u5206\uff0c\u4f8b\u5982\u201c\u6d59\u6c5f\u676d\u5ddexx\u201d\u3001\u201c\u6d59\u6c5f\u6e29\u5ddexx\u201d\uff0c\u8fd9\u91cc\u8ba2\u9605\u8005\u4e0d\u9700\u8981\u83b7\u53d6\u6d59\u6c5f\u7684\u6240\u6709\u5b50\u7c7b\u5728\u6328\u4e2a\u8ba2\u9605\uff0c\u53ea\u9700\u8981\u8c03\u7528psubscribe\u201c\u6d59\u6c5f*\u201d\u5c31\u80fd\u8ba2\u9605\u6240\u6709\u4ee5\u6d59\u6c5f\u5f00\u5934\u7684\u65b0\u95fb\u63a8\u9001\u4e86\uff0c\u8fd9\u91ccpsubscribe\u4f20\u5165\u4e00\u4e2a\u901a\u914d\u7b26\u8868\u8fbe\u7684channel\uff0cRedis\u670d\u52a1\u7aef\u6309\u7167\u89c4\u5219\u63a8\u9001\u6240\u6709\u5339\u914dchannel\u7684\u6d88\u606f\u7ed9\u5bf9\u5e94\u7684\u5ba2\u6237\u7aef\u3002<\/p>\n<p>#\u57fa\u4e8epubsub\u5b8c\u6210channel\u7684\u5339\u914d\u548c\u6d88\u606f\u7684\u5e7f\u64ad<\/p>\n<p>#\u6d88\u8d39\u80051\u8ba2\u9605channel1<br \/>subscribe channel1<br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;subscribe&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><br \/>#\u6536\u5230\u6d88\u606f\u63a8\u9001<br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;message&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;msg1&#8221;<\/span><\/p>\n<p>#\u6d88\u8d39\u80052\u8ba2\u9605channel<span style=\"margin: 0px;padding: 0px\">*<\/span><br \/>psubscribe channel<span style=\"margin: 0px;padding: 0px\">*<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;psubscribe&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><br \/>#\u6536\u5230\u6d88\u606f\u63a8\u9001<br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;msg1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;channel2&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;msg2&#8221;<\/span><\/p>\n<p>#\u751f\u4ea7\u8005\u53d1\u5e03\u6d88\u606fmsg1\u548cmsg2<br \/>publish channel1 msg1<br \/><span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">2<\/span><br \/>publish channel2 msg2<br \/><span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342163eddeaddb2ff.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p>\u5728Redfis 2.8\u65f6\u52a0\u5165\u4e86keyspace notifications\u529f\u80fd\uff0c\u6b64\u65f6pubsub\u9664\u4e86\u901a\u77e5\u7528\u6237\u81ea\u5b9a\u4e49\u6d88\u606f\uff0c\u4e5f\u53ef\u4ee5\u901a\u77e5\u7cfb\u7edf\u5185\u90e8\u6d88\u606f\u3002keyspace notifications\u5f15\u5165\u4e862\u4e2a\u7279\u6b8a\u7684channel\u5206\u522b\u662f__keyevent@__:\u548c__keyspace@__:\uff0c\u901a\u8fc7\u8ba2\u9605__keyevent\u5ba2\u6237\u7aef\u53ef\u4ee5\u6536\u5230\u67d0\u4e2a\u5177\u4f53\u547d\u4ee4\u8c03\u7528\u7684\u56de\u8c03\u901a\u77e5\uff0c\u901a\u8fc7\u8ba2\u9605__keyspace\u5ba2\u6237\u7aef\u53ef\u4ee5\u6536\u5230\u76ee\u6807key\u7684\u589e\u5220\u6539\u64cd\u4f5c\u4ee5\u53ca\u8fc7\u671f\u4e8b\u4ef6\u3002\u4f7f\u7528\u8fd9\u4e2a\u529f\u80fd\u8fd8\u9700\u8981\u5f00\u542f\u914d\u7f6enotify-keyspace-events\u3002<\/p>\n<p>#\u901a\u8fc7keyspace notifications\u529f\u80fd\u83b7\u53d6\u7cfb\u7edf\u4e8b\u4ef6<\/p>\n<p>#\u5199\u5165\u8bf7\u6c42<br \/><span style=\"margin: 0px;padding: 0px\">set<\/span> testkey v EX <span style=\"margin: 0px;padding: 0px\">1<\/span><\/p>\n<p>#\u8ba2\u9605key\u7ea7\u522b\u7684\u4e8b\u4ef6<br \/>psubscribe __keyspace@0__<span style=\"margin: 0px;padding: 0px\">:<\/span>testkey<br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;psubscribe&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><br \/>#\u6536\u5230\u901a\u77e5<br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;set&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;expire&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyspace@0__:testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;expired&#8221;<\/span><\/p>\n<p>#\u8ba2\u9605\u6240\u6709\u7684\u547d\u4ee4\u4e8b\u4ef6<br \/>psubscribe __keyevent@0__<span style=\"margin: 0px;padding: 0px\">:<\/span><span style=\"margin: 0px;padding: 0px\">*<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;psubscribe&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><br \/>#\u6536\u5230\u901a\u77e5<br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:set&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:expire&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;testkey&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;pmessage&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:*&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;__keyevent@0__:expired&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;testkey&#8221;<\/span><\/p>\n<p><\/p>\n<h4>2.pubsub\u7684\u4e0d\u8db3\u4e4b\u5904<\/h4>\n<p>pubsub\u65e2\u80fd\u5355\u64ad\u53c8\u80fd\u5e7f\u64ad\uff0c\u8fd8\u652f\u6301channel\u7684\u7b80\u5355\u6b63\u5219\u5339\u914d\uff0c\u529f\u80fd\u4e0a\u5df2\u7ecf\u80fd\u6ee1\u8db3\u5927\u90e8\u5206\u4e1a\u52a1\u7684\u9700\u6c42\uff0c\u800c\u4e14\u8fd9\u4e2a\u63a5\u53e3\u53d1\u5e03\u7684\u65f6\u95f4\u5f88\u65e9\uff0c\u57282011\u5e74Redis 2.0\u53d1\u5e03\u65f6\u5c31\u5df2\u7ecf\u5177\u5907\uff0c\u7528\u6237\u57fa\u7840\u5f88\u5e7f\u6cdb\uff0c\u6240\u4ee5\u73b0\u5728\u5f88\u591a\u4e1a\u52a1\u90fd\u6709\u7528\u5230\u8fd9\u4e2a\u529f\u80fd\u3002\u4f46\u4f60\u8981\u6df1\u5165\u4e86\u89e3pubsub\u7684\u539f\u7406\u540e\uff0c\u662f\u80af\u5b9a\u4e0d\u6562\u628a\u5b83\u4f5c\u4e3a\u4e00\u4e2a\u4e00\u81f4\u6027\u8981\u6c42\u8f83\u9ad8\uff0c\u6570\u636e\u91cf\u8f83\u5927\u7cfb\u7edf\u7684\u6d88\u606f\u670d\u52a1\u7684\u3002<\/p>\n<p>\u9996\u5148\uff0cpubsub\u7684\u6d88\u606f\u6570\u636e\u662f\u77ac\u65f6\u7684\uff0c\u5b83\u5728Redis\u670d\u52a1\u7aef\u4e0d\u505a\u4fdd\u5b58\uff0cpublish\u53d1\u9001\u5230Redis\u7684\u6d88\u606f\u4f1a\u7acb\u523b\u63a8\u9001\u5230\u6240\u6709\u5f53\u65f6subscribe\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\uff0c\u5982\u679c\u5f53\u65f6\u5ba2\u6237\u7aef\u56e0\u4e3a\u7f51\u7edc\u95ee\u9898\u65ad\u8fde\uff0c\u90a3\u4e48\u5c31\u4f1a\u9519\u8fc7\u8fd9\u6761\u6d88\u606f\uff0c\u5f53\u5ba2\u6237\u7aef\u91cd\u8fde\u540e\uff0c\u5b83\u6ca1\u6cd5\u91cd\u65b0\u83b7\u53d6\u4e4b\u524d\u90a3\u6761\u6d88\u606f\uff0c\u751a\u81f3\u65e0\u6cd5\u5224\u65ad\u662f\u5426\u6709\u6d88\u606f\u4e22\u5931\u3002<\/p>\n<p>\u5176\u6b21\uff0cpubsub\u4e2d\u6d88\u8d39\u8005\u83b7\u53d6\u6d88\u606f\u662f\u4e00\u4e2a\u63a8\u9001\u6a21\u578b\uff0c\u8fd9\u610f\u5473\u7740Redis\u4f1a\u6309\u6d88\u606f\u751f\u4ea7\u7684\u901f\u5ea6\u7ed9\u6240\u6709\u7684\u6d88\u8d39\u8005\u63a8\u9001\u6d88\u606f\uff0c\u4e0d\u7ba1\u6d88\u8d39\u8005\u5904\u7406\u80fd\u529b\u5982\u4f55\uff0c\u5982\u679c\u6d88\u8d39\u8005\u5e94\u7528\u5904\u7406\u80fd\u529b\u4e0d\u8db3\uff0c\u6d88\u606f\u5c31\u4f1a\u5728Redis\u7684client buf\u4e2d\u5806\u79ef\uff0c\u5f53\u5806\u79ef\u6570\u636e\u8d85\u8fc7\u4e00\u4e2a\u9608\u503c\u540e\u4f1a\u65ad\u5f00\u8fd9\u6761\u8fde\u63a5\uff0c\u8fd9\u610f\u5473\u7740\u8fd9\u4e9b\u6d88\u606f\u5168\u90e8\u4e22\u5931\u4e86\uff0c\u5728\u4e5f\u627e\u4e0d\u56de\u6765\u4e86\u3002\u5982\u679c\u540c\u65f6\u6709\u591a\u4e2a\u6d88\u8d39\u8005\u7684client buf\u5806\u79ef\u6570\u636e\u4f46\u53c8\u8fd8\u6ca1\u8fbe\u5230\u65ad\u5f00\u8fde\u63a5\u7684\u9608\u503c\uff0c\u90a3\u4e48Redis\u670d\u52a1\u7aef\u7684\u5185\u5b58\u4f1a\u81a8\u80c0\uff0c\u8fdb\u7a0b\u53ef\u80fd\u56e0\u4e3aoom\u800c\u88ab\u6740\u6389\uff0c\u8fd9\u5bfc\u81f4\u4e86\u6574\u4e2a\u670d\u52a1\u4e2d\u65ad\u3002<\/p>\n<h4>3.\u603b\u7ed3<\/h4>\n<p><strong>\u4f18\u52bf<\/strong><\/p>\n<ul>\n<li>\u6d88\u606f\u5177\u5907\u5e7f\u64ad\u80fd\u529b<\/li>\n<li>psubscribe\u80fd\u6309\u5b57\u7b26\u4e32\u901a\u914d\u7b26\u5339\u914d\uff0c\u7ed9\u4e88\u4e86\u4e1a\u52a1\u903b\u8f91\u7684\u7075\u6d3b\u6027<\/li>\n<li>\u80fd\u8ba2\u9605\u7279\u5b9akey\u6216\u7279\u5b9a\u547d\u4ee4\u7684\u7cfb\u7edf\u6d88\u606f<\/li>\n<\/ul>\n<p><strong>\u4e0d\u8db3<\/strong><\/p>\n<ul>\n<li>Redis\u5f02\u5e38\u3001\u5ba2\u6237\u7aef\u65ad\u8fde\u90fd\u4f1a\u5bfc\u81f4\u6d88\u606f\u4e22\u5931<\/li>\n<li>\u6d88\u606f\u7f3a\u4e4f\u5806\u79ef\u80fd\u529b\uff0c\u4e0d\u80fd\u524a\u5cf0\u586b\u8c37\u3002\u63a8\u9001\u7684\u65b9\u5f0f\u7f3a\u4e4f\u80cc\u538b\u673a\u5236\uff0c\u6ca1\u6709\u8003\u8651\u6d88\u8d39\u8005\u5904\u7406\u80fd\u529b\uff0c\u63a8\u9001\u7684\u6d88\u606f\u8d85\u8fc7\u6d88\u8d39\u8005\u5904\u7406\u80fd\u529b\u540e\u53ef\u80fd\u5bfc\u81f4\u6d88\u606f\u4e22\u5931\u6216\u670d\u52a1\u5f02\u5e38<\/li>\n<\/ul>\n<h3>\u4e09\u3001Redis 5.0 stream<\/h3>\n<p>\u6d88\u606f\u4e22\u5931\u3001\u6d88\u606f\u670d\u52a1\u4e0d\u7a33\u5b9a\u7684\u95ee\u9898\u4e25\u91cd\u9650\u5236\u4e86pubsub\u7684\u5e94\u7528\u573a\u666f\uff0c\u6240\u4ee5Redis\u9700\u8981\u91cd\u65b0\u8bbe\u8ba1\u4e00\u5957\u673a\u5236\uff0c\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u8fd9\u5c31\u6709\u4e86\u540e\u6765\u7684stream\u7ed3\u6784\u3002<\/p>\n<h4>1.stream\u7279\u6027<\/h4>\n<p>\u4e00\u4e2a\u7a33\u5b9a\u7684\u6d88\u606f\u670d\u52a1\u9700\u8981\u5177\u5907\u51e0\u4e2a\u8981\u70b9\uff0c\u8981\u4fdd\u8bc1\u6d88\u606f\u4e0d\u4f1a\u4e22\u5931\uff0c\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21\uff0c\u8981\u5177\u5907\u524a\u5cf0\u586b\u8c37\u7684\u80fd\u529b\uff0c\u6765\u5339\u914d\u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005\u541e\u5410\u7684\u5dee\u5f02\u3002\u57282018\u5e74Redis 5.0\u52a0\u5165\u4e86stream\u7ed3\u6784\uff0c\u8fd9\u6b21\u8003\u8651\u4e86list\u3001pubsub\u5728\u5e94\u7528\u573a\u666f\u4e0b\u7684\u7f3a\u9677\uff0c\u5bf9\u6807kafka\u7684\u6a21\u578b\u91cd\u65b0\u8bbe\u8ba1\u5168\u5185\u5b58\u6d88\u606f\u961f\u5217\u7ed3\u6784\uff0c\u4ece\u8fd9\u65f6\u5f00\u59cbRedis\u6d88\u606f\u961f\u5217\u529f\u80fd\u7b97\u662f\u80fd\u548c\u4e3b\u6d41\u6d88\u606f\u961f\u5217\u4ea7\u54c1pk\u4e00\u628a\u4e86\u3002<\/p>\n<p>stream\u7684\u6539\u8fdb\u5206\u4e3a\u591a\u4e2a\u65b9\u9762<\/p>\n<p><strong>\u6210\u672c\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b58\u50a8message\u6570\u636e\u4f7f\u7528\u4e86listpack\u7ed3\u6784\uff0c\u8fd9\u662f\u4e00\u4e2a\u7d27\u51d1\u578b\u7684\u6570\u636e\u7ed3\u6784\uff0c\u4e0d\u540c\u4e8elist\u7684\u53cc\u5411\u94fe\u8868\u6bcf\u4e2a\u8282\u70b9\u90fd\u8981\u989d\u5916\u5360\u75282\u4e2a\u6307\u9488\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u8fd9\u4f7f\u5f97\u5c0fmsg\u60c5\u51b5\u4e0bstream\u7684\u7a7a\u95f4\u5229\u7528\u7387\u66f4\u9ad8\u3002<\/li>\n<\/ul>\n<p><strong>\u529f\u80fd\uff1a<\/strong><\/p>\n<ul>\n<li>stream\u5f15\u5165\u4e86\u6d88\u8d39\u8005\u7ec4\u7684\u6982\u5ff5\uff0c\u4e00\u4e2a\u6d88\u8d39\u8005\u7ec4\u5185\u53ef\u4ee5\u6709\u591a\u4e2a\u6d88\u8d39\u8005\uff0c\u540c\u4e00\u4e2a\u7ec4\u5185\u7684\u6d88\u8d39\u8005\u5171\u4eab\u4e00\u4e2a\u6d88\u606f\u4f4d\u70b9(last_delivered_id)\uff0c\u8fd9\u4f7f\u5f97\u6d88\u8d39\u8005\u80fd\u591f\u6c34\u5e73\u7684\u6269\u5bb9\uff0c\u53ef\u4ee5\u5728\u4e00\u4e2a\u7ec4\u5185\u52a0\u5165\u591a\u4e2a\u6d88\u8d39\u8005\u6765\u7ebf\u6027\u7684\u63d0\u5347\u541e\u5410\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u6d88\u8d39\u8005\u7ec4\uff0c\u6bcf\u6761msg\u53ea\u4f1a\u88ab\u5176\u4e2d\u4e00\u4e2a\u6d88\u8d39\u8005\u83b7\u53d6\u548c\u5904\u7406\uff0c\u8fd9\u662fpubsub\u7684\u5e7f\u64ad\u6a21\u578b\u4e0d\u5177\u5907\u7684\u3002<\/li>\n<li>\u4e0d\u540c\u6d88\u8d39\u8005\u7ec4\u4e4b\u524d\u662f\u76f8\u4e92\u9694\u79bb\u7684\uff0c\u4ed6\u4eec\u5404\u81ea\u7ef4\u62a4\u81ea\u5df1\u7684\u4f4d\u70b9\uff0c\u8fd9\u4f7f\u5f97\u4e00\u6761msg\u80fd\u88ab\u591a\u4e2a\u4e0d\u540c\u7684\u6d88\u8d39\u8005\u7ec4\u91cd\u590d\u6d88\u8d39\uff0c\u505a\u5230\u4e86\u6d88\u606f\u5e7f\u64ad\u7684\u80fd\u529b\u3002<\/li>\n<li>stream\u4e2d\u6d88\u8d39\u8005\u91c7\u7528\u62c9\u53d6\u7684\u65b9\u5f0f\uff0c\u5e76\u80fd\u8bbe\u7f6etimeout\u5728\u6ca1\u6709\u6d88\u606f\u65f6\u963b\u585e\uff0c\u901a\u8fc7\u8fd9\u79cd\u957f\u8f6e\u8be2\u673a\u5236\u4fdd\u8bc1\u4e86\u6d88\u606f\u7684\u5b9e\u65f6\u6027\uff0c\u800c\u4e14\u6d88\u8d39\u901f\u7387\u662f\u548c\u6d88\u8d39\u8005\u81ea\u8eab\u541e\u5410\u76f8\u5339\u914d\u3002<\/li>\n<\/ul>\n<p>\u6d88\u606f\u4e0d\u4e22\u5931\uff1a<\/p>\n<ul>\n<li>stream\u7684\u6570\u636e\u4f1a\u5b58\u50a8\u5728aof\u548crdb\u6587\u4ef6\u4e2d\uff0c\u8fd9\u4f7fRedis\u91cd\u542f\u540e\u80fd\u591f\u6062\u590dstream\u7684\u6570\u636e\u3002\u800cpubsub\u7684\u6570\u636e\u662f\u77ac\u65f6\u7684\uff0cRedis\u91cd\u542f\u610f\u5473\u7740\u6d88\u606f\u5168\u90e8\u4e22\u5931\u3002<\/li>\n<li>stream\u4e2d\u6bcf\u4e2a\u6d88\u8d39\u8005\u7ec4\u4f1a\u5b58\u50a8\u4e00\u4e2alast_delivered_id\u6765\u6807\u8bc6\u5df2\u7ecf\u8bfb\u53d6\u5230\u7684\u4f4d\u70b9\uff0c\u5ba2\u6237\u7aef\u8fde\u63a5\u65ad\u5f00\u540e\u91cd\u8fde\u8fd8\u662f\u80fd\u4ece\u8be5\u4f4d\u70b9\u7ee7\u7eed\u8bfb\u53d6\uff0c\u6d88\u606f\u4e0d\u4f1a\u4e22\u5931\u3002<\/li>\n<li>stream\u5f15\u5165\u4e86ack\u673a\u5236\u4fdd\u8bc1\u6d88\u606f\u81f3\u5c11\u88ab\u5904\u7406\u4e00\u6b21\u3002\u8003\u8651\u4e00\u79cd\u573a\u666f\uff0c\u5982\u679c\u6d88\u8d39\u8005\u5e94\u7528\u5df2\u7ecf\u8bfb\u53d6\u4e86\u6d88\u606f\uff0c\u4f46\u8fd8\u6ca1\u6765\u5f97\u53ca\u5904\u7406\u5e94\u7528\u5c31\u5b95\u673a\u4e86\uff0c\u5bf9\u4e8e\u8fd9\u79cd\u5df2\u7ecf\u8bfb\u53d6\u4f46\u6ca1\u6709ack\u7684\u6d88\u606f\uff0cstream\u4f1a\u6807\u793a\u8fd9\u6761\u6d88\u606f\u7684\u72b6\u6001\u4e3apending\uff0c\u7b49\u5ba2\u6237\u7aef\u91cd\u8fde\u540e\u901a\u8fc7xpending\u547d\u4ee4\u53ef\u4ee5\u91cd\u65b0\u8bfb\u53d6\u5230pengind\u72b6\u6001\u7684\u6d88\u606f\uff0c\u7ee7\u7eed\u5904\u7406\u3002\u5982\u679c\u8fd9\u4e2a\u5e94\u7528\u6c38\u4e45\u5b95\u673a\u4e86\uff0c\u90a3\u4e48\u8be5\u6d88\u8d39\u8005\u7ec4\u5185\u7684\u5176\u4ed6\u6d88\u8d39\u8005\u5e94\u7528\u4e5f\u80fd\u8bfb\u53d6\u5230\u8fd9\u6761\u6d88\u606f\uff0c\u5e76\u901a\u8fc7xclaim\u547d\u4ee4\u5c06\u5b83\u5f52\u5c5e\u5230\u81ea\u5df1\u4e0b\u9762\u7ee7\u7eed\u5904\u7406\u3002<\/li>\n<\/ul>\n<p>#\u57fa\u4e8estream\u5b8c\u6210\u6d88\u606f\u7684\u751f\u4ea7\u548c\u6d88\u8d39\uff0c\u5e76\u786e\u4fdd\u5f02\u5e38\u72b6\u6001\u4e0b\u6d88\u606f\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21<\/p>\n<p>#\u521b\u5efamystream\uff0c\u5e76\u4e14\u521b\u5efa\u4e00\u4e2aconsumergroup\u4e3amygroup<br \/>XGROUP <span style=\"margin: 0px;padding: 0px\">CREATE<\/span> mystream mygroup $ MKSTREAM<br \/>OK<\/p>\n<p>#\u5199\u5165\u4e00\u6761\u6d88\u606f\uff0c\u7531redis\u81ea\u52a8\u751f\u6210\u6d88\u606fid\uff0c\u6d88\u606f\u7684\u5185\u5bb9\u662f\u4e00\u4e2akv\u6570\u7ec4\uff0c\u8fd9\u91cc\u5305\u542bfield1 value1 field2 value2<br \/>XADD mystream <span style=\"margin: 0px;padding: 0px\">*<\/span> field1 value1 field2 value2<br \/><span style=\"margin: 0px;padding: 0px\">&#8220;1645517760385-0&#8221;<\/span><\/p>\n<p>#\u6d88\u8d39\u8005\u7ec4mygroup\u4e2d\u7684\u6d88\u8d39\u8005consumer1\u4ecemystream\u8bfb\u53d6\u4e00\u6761\u6d88\u606f\uff0c<span style=\"margin: 0px;padding: 0px\">&gt;<\/span>\u8868\u793a\u8bfb\u53d6\u4e00\u6761\u8be5\u6d88\u8d39\u8005\u7ec4\u4ece\u672a\u8bfb\u53d6\u8fc7\u7684\u6d88\u606f<br \/>XREADGROUP <span style=\"margin: 0px;padding: 0px\">GROUP<\/span> mygroup consumer1 <span style=\"margin: 0px;padding: 0px\">COUNT<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span> STREAMS mystream <span style=\"margin: 0px;padding: 0px\">&gt;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;mystream&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;1645517760385-0&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;field1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;value1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;field2&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;value2&#8221;<\/span><\/p>\n<p>#\u6d88\u8d39\u5b8c\u6210\u540eack\u786e\u8ba4\u6d88\u606f<br \/>xack mystream mygroup <span style=\"margin: 0px;padding: 0px\">1645517760385<\/span><span style=\"margin: 0px;padding: 0px\">&#8211;<\/span><span style=\"margin: 0px;padding: 0px\">0<\/span><br \/><span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><\/p>\n<p>#\u5982\u679c\u6d88\u8d39\u8005\u5e94\u7528\u5728ack\u524d\u5f02\u5e38\u5b95\u673a\uff0c\u6062\u590d\u540e\u91cd\u65b0\u83b7\u53d6\u672a\u5904\u7406\u7684\u6d88\u606fid\u3002<br \/>XPENDING mystream mygroup <span style=\"margin: 0px;padding: 0px\">&#8211;<\/span> <span style=\"margin: 0px;padding: 0px\">+<\/span> <span style=\"margin: 0px;padding: 0px\">10<\/span> <br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;1645517760385-0&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;consumer1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">305356<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">(<\/span><span style=\"margin: 0px;padding: 0px\">integer<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><\/p>\n<p> #\u5982\u679cconsumer1\u6c38\u8fdc\u5b95\u673a\uff0c\u5176\u4ed6\u6d88\u8d39\u8005\u53ef\u4ee5\u628apending\u72b6\u6001\u7684\u6d88\u606f\u79fb\u52a8\u5230\u81ea\u5df1\u540d\u4e0b\u540e\u7ee7\u7eed\u6d88\u8d39<br \/> #\u5c06\u6d88\u606fid <span style=\"margin: 0px;padding: 0px\">1645517760385<\/span><span style=\"margin: 0px;padding: 0px\">&#8211;<\/span><span style=\"margin: 0px;padding: 0px\">0<\/span>\u79fb\u52a8\u5230consumer2\u4e0b<br \/> XCLAIM mystream mygroup consumer2 <span style=\"margin: 0px;padding: 0px\">0<\/span> <span style=\"margin: 0px;padding: 0px\">1645517760385<\/span><span style=\"margin: 0px;padding: 0px\">&#8211;<\/span><span style=\"margin: 0px;padding: 0px\">0<\/span><br \/><span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;1645517760385-0&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">1<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;field1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">2<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;value1&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">3<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;field2&#8221;<\/span><br \/><span style=\"margin: 0px;padding: 0px\">4<\/span><span style=\"margin: 0px;padding: 0px\">)<\/span> <span style=\"margin: 0px;padding: 0px\">&#8220;value2&#8221;<\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342263eddeae60036.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p>Redis stream\u4fdd\u8bc1\u4e86\u6d88\u606f\u81f3\u5c11\u88ab\u5904\u7406\u4e00\u6b21\uff0c\u4f46\u5982\u679c\u60f3\u505a\u5230\u6bcf\u6761\u6d88\u606f\u4ec5\u88ab\u5904\u7406\u4e00\u6b21\u8fd8\u9700\u8981\u5e94\u7528\u903b\u8f91\u7684\u4ecb\u5165\u3002<\/p>\n<p>\u6d88\u606f\u88ab\u91cd\u590d\u5904\u7406\u8981\u4e48\u662f\u751f\u4ea7\u8005\u91cd\u590d\u6295\u9012\uff0c\u8981\u4e48\u662f\u6d88\u8d39\u8005\u91cd\u590d\u6d88\u8d39\u3002<\/p>\n<ul>\n<li>\u5bf9\u4e8e\u751f\u4ea7\u8005\u91cd\u590d\u6295\u9012\u95ee\u9898\uff0cRedis stream\u4e3a\u6bcf\u4e2a\u6d88\u606f\u90fd\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u552f\u4e00\u9012\u589e\u7684id\uff0c\u901a\u8fc7\u53c2\u6570\u53ef\u4ee5\u8ba9Redis\u81ea\u52a8\u751f\u6210id\u6216\u8005\u5e94\u7528\u81ea\u5df1\u6307\u5b9aid\uff0c\u5e94\u7528\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u903b\u8f91\u4e3a\u6bcf\u4e2amsg\u751f\u6210id\uff0c\u5f53xadd\u8d85\u65f6\u540e\u5e94\u7528\u5e76\u4e0d\u80fd\u786e\u5b9a\u6d88\u606f\u662f\u5426\u6295\u9012\u6210\u529f\uff0c\u53ef\u4ee5\u901a\u8fc7xread\u67e5\u8be2\u8be5id\u7684\u6d88\u606f\u662f\u5426\u5b58\u5728\uff0c\u5b58\u5728\u5c31\u8bf4\u660e\u5df2\u7ecf\u6295\u9012\u6210\u529f\uff0c\u4e0d\u5b58\u5728\u5219\u91cd\u65b0\u6295\u9012\uff0c\u800c\u4e14stream\u9650\u5236\u4e86id\u5fc5\u987b\u9012\u589e\uff0c\u8fd9\u610f\u5473\u4e86\u5df2\u7ecf\u5b58\u5728\u7684\u6d88\u606f\u91cd\u590d\u6295\u9012\u4f1a\u88ab\u62d2\u7edd\u3002\u8fd9\u5957\u673a\u5236\u4fdd\u8bc1\u4e86\u6bcf\u4e2a\u6d88\u606f\u53ef\u4ee5\u4ec5\u88ab\u6295\u9012\u4e00\u6b21\u3002<\/li>\n<li>\u5bf9\u4e8e\u6d88\u8d39\u8005\u91cd\u590d\u6d88\u8d39\u7684\u95ee\u9898\uff0c\u8003\u8651\u4e00\u4e2a\u573a\u666f\uff0c\u6d88\u8d39\u8005\u8bfb\u53d6\u6d88\u606f\u540e\u4e1a\u52a1\u5904\u7406\u5b8c\u6bd5\uff0c\u4f46\u8fd8\u6ca1\u6765\u5f97\u53caack\u5c31\u53d1\u751f\u4e86\u5f02\u5e38\uff0c\u5e94\u7528\u6062\u590d\u540e\u5bf9\u4e8e\u8fd9\u6761\u6ca1\u6709ack\u7684\u6d88\u606f\u8fdb\u884c\u4e86\u91cd\u590d\u6d88\u8d39\u3002\u8fd9\u4e2a\u95ee\u9898\u56e0\u4e3aack\u548c\u6d88\u8d39\u6d88\u606f\u7684\u4e1a\u52a1\u903b\u8f91\u53d1\u751f\u57282\u4e2a\u7cfb\u7edf\uff0c\u6ca1\u6cd5\u505a\u5230\u4e8b\u52a1\u6027\uff0c\u9700\u8981\u4e1a\u52a1\u6765\u6539\u9020\uff0c\u4fdd\u8bc1\u6d88\u606f\u5904\u7406\u7684\u5e42\u7b49\u6027\u3002<\/li>\n<\/ul>\n<h4>2.stream\u7684\u4e0d\u8db3<\/h4>\n<p>stream\u7684\u6a21\u578b\u505a\u5230\u4e86\u6d88\u606f\u7684\u9ad8\u6548\u5206\u53d1\uff0c\u800c\u4e14\u4fdd\u8bc1\u4e86\u6d88\u606f\u81f3\u5c11\u88ab\u5904\u7406\u4e00\u6b21\uff0c\u901a\u8fc7\u5e94\u7528\u903b\u8f91\u7684\u6539\u9020\u80fd\u505a\u5230\u6d88\u606f\u4ec5\u88ab\u5904\u7406\u4e00\u6b21\uff0c\u5b83\u7684\u80fd\u529b\u5bf9\u6807kafka\uff0c\u4f46\u541e\u5410\u9ad8\u4e8ekafka\uff0c\u5728\u9ad8\u541e\u5410\u573a\u666f\u4e0b\u6210\u672c\u6bd4kafka\u4f4e\uff0c\u90a3\u5b83\u53c8\u6709\u54ea\u4e9b\u4e0d\u8db3\u4e86\u3002<\/p>\n<p>\u9996\u5148\u6d88\u606f\u961f\u5217\u5f88\u91cd\u8981\u7684\u4e00\u4e2a\u529f\u80fd\u5c31\u662f\u524a\u5cf0\u586b\u8c37\uff0c\u6765\u5339\u914d\u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005\u541e\u5410\u7684\u5dee\u5f02\uff0c\u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005\u541e\u5410\u5dee\u5f02\u8d8a\u5927\uff0c\u6301\u7eed\u65f6\u95f4\u8d8a\u957f\uff0c\u5c31\u610f\u5473\u7740steam\u4e2d\u9700\u8981\u5806\u79ef\u66f4\u591a\u7684\u6d88\u606f\uff0c\u800cRedis\u4f5c\u4e3a\u4e00\u4e2a\u5168\u5185\u5b58\u7684\u4ea7\u54c1\uff0c\u6570\u636e\u5806\u79ef\u7684\u6210\u672c\u6bd4\u78c1\u76d8\u9ad8\u3002<\/p>\n<p>\u5176\u6b21stream\u901a\u8fc7ack\u673a\u5236\u4fdd\u8bc1\u4e86\u6d88\u606f\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21\uff0c\u4f46\u8fd9\u6709\u4e2a\u524d\u63d0\u5c31\u662f\u5b58\u50a8\u5728Redis\u4e2d\u7684\u6d88\u606f\u672c\u8eab\u4e0d\u4f1a\u4e22\u5931\u3002Redis\u6570\u636e\u7684\u6301\u4e45\u5316\u4f9d\u8d56aof\u548crdb\u6587\u4ef6\uff0caof\u843d\u76d8\u65b9\u5f0f\u6709\u51e0\u79cd\uff0c\u901a\u8fc7\u914d\u7f6eappendfsync\u51b3\u5b9a\uff0c\u901a\u5e38\u6211\u4eec\u4e0d\u4f1a\u914d\u7f6e\u4e3aalways\u6765\u8ba9\u6bcf\u6761\u547d\u4ee4\u6267\u884c\u5b8c\u540e\u90fd\u505a\u4e00\u6b21fsync\uff0c\u7ebf\u4e0a\u914d\u7f6e\u4e00\u822c\u4e3aeverysec\uff0c\u6bcf\u79d2\u505a\u4e00\u6b21fsync\uff0c\u800crdb\u662f\u5168\u91cf\u5907\u4efd\u65f6\u751f\u6210\uff0c\u8fd9\u610f\u5473\u4e86\u5b95\u673a\u6062\u590d\u53ef\u80fd\u4f1a\u4e22\u6389\u6700\u8fd1\u4e00\u79d2\u7684\u6570\u636e\u3002\u53e6\u4e00\u65b9\u9762\u7ebf\u4e0a\u751f\u4ea7\u73af\u5883\u7684Redis\u90fd\u662f\u9ad8\u53ef\u7528\u67b6\u6784\uff0c\u5f53\u4e3b\u8282\u70b9\u5b95\u673a\u540e\u901a\u5e38\u4e0d\u4f1a\u8d70\u6062\u590d\u903b\u8f91\uff0c\u800c\u662f\u76f4\u63a5\u5207\u6362\u5230\u5907\u8282\u70b9\u7ee7\u7eed\u63d0\u4f9b\u670d\u52a1\uff0c\u800cRedis\u7684\u540c\u6b65\u65b9\u5f0f\u662f\u5f02\u6b65\u540c\u6b65\uff0c\u8fd9\u610f\u5473\u7740\u4e3b\u8282\u70b9\u4e0a\u65b0\u5199\u5165\u7684\u6570\u636e\u53ef\u80fd\u8fd8\u6ca1\u540c\u6b65\u5230\u5907\u8282\u70b9\uff0c\u5728\u5207\u6362\u540e\u8fd9\u90e8\u5206\u6570\u636e\u5c31\u4e22\u5931\u4e86\u3002\u6240\u4ee5\u5728\u6545\u969c\u6062\u590d\u4e2dRedis\u4e2d\u7684\u6570\u636e\u53ef\u80fd\u4f1a\u4e22\u5931\u4e00\u90e8\u5206\uff0c\u5728\u8fd9\u6837\u7684\u80cc\u666f\u4e0b\u65e0\u8bbastream\u7684\u63a5\u53e3\u8bbe\u8ba1\u7684\u591a\u4e48\u5b8c\u5584\uff0c\u90fd\u4e0d\u80fd\u4fdd\u8bc1\u6d88\u606f\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21\u3002<\/p>\n<h4>3.\u603b\u7ed3<\/h4>\n<p><strong>\u4f18\u52bf<\/strong><\/p>\n<ul>\n<li>\u5728\u6210\u672c\u3001\u529f\u80fd\u4e0a\u505a\u4e86\u5f88\u591a\u6539\u8fdb\uff0c\u652f\u6301\u4e86\u7d27\u51d1\u7684\u5b58\u50a8\u5c0f\u6d88\u606f\u3001\u5177\u5907\u5e7f\u64ad\u80fd\u529b\u3001\u6d88\u8d39\u8005\u80fd\u6c34\u5e73\u6269\u5bb9\u3001\u5177\u5907\u80cc\u538b\u673a\u5236<\/li>\n<li>\u901a\u8fc7ack\u673a\u5236\u4fdd\u8bc1\u4e86Redis\u670d\u52a1\u7aef\u6b63\u5e38\u60c5\u51b5\u4e0b\u6d88\u606f\u81f3\u5c11\u88ab\u5904\u7406\u4e00\u6b21\u7684\u80fd\u529b<\/li>\n<\/ul>\n<p><strong>\u4e0d\u8db3<\/strong><\/p>\n<ul>\n<li>\u5185\u5b58\u578b\u6d88\u606f\u961f\u5217\uff0c\u6570\u636e\u5806\u79ef\u6210\u672c\u9ad8<\/li>\n<li>Redis\u672c\u8eabrpo&gt;0\uff0c\u6545\u969c\u6062\u590d\u53ef\u80fd\u4f1a\u4e22\u6570\u636e\uff0c\u6240\u4ee5stream\u5728Redis\u53d1\u751f\u6545\u969c\u6062\u590d\u540e\u4e5f\u4e0d\u80fd\u4fdd\u8bc1\u6d88\u606f\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21\u3002<\/li>\n<\/ul>\n<h3>\u56db\u3001Tair\u6301\u4e45\u5185\u5b58\u7248 stream<\/h3>\n<p>Redis stream\u7684\u4e0d\u8db3\u4e5f\u662f\u5185\u5b58\u578b\u6570\u636e\u5e93\u7279\u6027\u5e26\u6765\u7684\uff0c\u5b83\u62e5\u6709\u9ad8\u541e\u5410\u3001\u4f4e\u5ef6\u65f6\uff0c\u4f46\u5927\u5bb9\u91cf\u4e0b\u6210\u672c\u4f1a\u6bd4\u8f83\u9ad8\uff0c\u800c\u5e94\u7528\u7684\u573a\u666f\u4e5f\u4e0d\u5b8c\u5168\u662f\u7edd\u5bf9\u7684\u5927\u5bb9\u91cf\u4f4e\u541e\u5410\u6216\u5c0f\u5bb9\u91cf\u9ad8\u541e\u5410\uff0c\u6709\u65f6\u5e94\u7528\u7684\u573a\u666f\u4f1a\u4ecb\u4e8e\u4e8c\u8005\u4e4b\u95f4\uff0c\u9700\u8981\u5e73\u8861\u5bb9\u91cf\u548c\u541e\u5410\u7684\u5173\u7cfb\uff0c\u6240\u4ee5\u9700\u8981\u4e00\u4e2a\u4ea7\u54c1\u5b83\u7684\u5b58\u50a8\u6210\u672c\u4f4e\u4e8eRedis stream\uff0c\u4f46\u5b83\u7684\u6027\u80fd\u53c8\u9ad8\u4e8e\u78c1\u76d8\u578b\u6d88\u606f\u961f\u5217\u3002<\/p>\n<p>\u53e6\u4e00\u65b9\u9762Redis stream\u5728Redis\u6545\u969c\u573a\u666f\u4e0b\u4e0d\u80fd\u4fdd\u8bc1\u6d88\u606f\u7684\u4e0d\u4e22\u5931\uff0c\u8fd9\u5bfc\u81f4\u4e1a\u52a1\u9700\u8981\u81ea\u5df1\u5b9e\u73b0\u4e00\u4e9b\u590d\u6742\u7684\u673a\u5236\u6765\u56de\u8865\u8fd9\u6bb5\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u9650\u5236\u4e86\u5b83\u5e94\u7528\u5728\u4e00\u4e9b\u5bf9\u4e00\u81f4\u6027\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f\u3002\u4e3a\u4e86\u8ba9\u4e1a\u52a1\u903b\u8f91\u66f4\u7b80\u5355\uff0cstream\u5e94\u7528\u8303\u56f4\u66f4\u5e7f\uff0c\u9700\u8981\u4fdd\u8bc1\u6545\u969c\u573a\u666f\u4e0b\u7684\u6d88\u606f\u6301\u4e45\u5316\u3002<\/p>\n<p>\u517c\u987e\u6210\u672c\u3001\u6027\u80fd\u3001\u6301\u4e45\u5316\uff0c\u8fd9\u5c31\u6709\u4e86Tair\u6301\u4e45\u5185\u5b58\u7248\u3002<\/p>\n<h4>1.Tair\u6301\u4e45\u5185\u5b58\u7248\u7279\u6027<\/h4>\n<p><strong>\u66f4\u5927\u7a7a\u95f4\uff0c\u66f4\u4f4e\u6210\u672c<\/strong><\/p>\n<p>Tair\u6301\u4e45\u5185\u5b58\u7248\u5f15\u5165\u4e86Intel\u50b2\u817e\u6301\u4e45\u5185\u5b58(\u4e0b\u9762\u79f0\u4f5cAEP)\uff0c\u5b83\u7684\u6027\u80fd\u7565\u4f4e\u4e8e\u5185\u5b58\uff0c\u4f46\u76f8\u540c\u5bb9\u91cf\u4e0b\u6210\u672c\u4f4e\u4e8e\u5185\u5b58\u3002Tair\u6301\u4e45\u5185\u5b58\u7248\u5c06\u4e3b\u8981\u6570\u636e\u5b58\u50a8\u5728AEP\u4e0a\uff0c\u4f7f\u5f97\u76f8\u540c\u5bb9\u91cf\u4e0b\uff0c\u6210\u672c\u66f4\u4f4e\uff0c\u8fd9\u4f7f\u540c\u6837\u5355\u4ef7\u4e0bstream\u80fd\u5806\u79ef\u66f4\u591a\u7684\u6d88\u606f\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342263eddeaec1aeb.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p><strong>\u517c\u5bb9\u793e\u533a\u7248<\/strong><\/p>\n<p>Tair\u6301\u4e45\u5185\u5b58\u7248\u517c\u5bb9\u539f\u751fRedis\u7edd\u5927\u90e8\u5206\u7684\u6570\u636e\u7ed3\u6784\u548c\u63a5\u53e3\uff0c\u5bf9\u4e8estream\u76f8\u5173\u63a5\u53e3\u505a\u5230\u4e86100%\u517c\u5bb9\uff0c\u5982\u679c\u4f60\u4e4b\u524d\u4f7f\u7528\u4e86\u793e\u533a\u7248stream\uff0c\u90a3\u4e48\u4e0d\u9700\u8981\u4fee\u6539\u4efb\u4f55\u4ee3\u7801\uff0c\u53ea\u9700\u8981\u6362\u4e00\u4e2a\u8fde\u63a5\u5730\u5740\u5c31\u80fd\u5207\u6362\u5230\u6301\u4e45\u5185\u5b58\u7248\u3002\u5e76\u4e14\u901a\u8fc7\u5de5\u5177\u5b8c\u6210\u793e\u533a\u7248\u548c\u6301\u4e45\u5185\u5b58\u7248\u6570\u636e\u7684\u53cc\u5411\u8fc1\u79fb\u3002<\/p>\n<p><strong>\u6570\u636e\u7684\u5b9e\u65f6\u6301\u4e45\u5316<\/strong><\/p>\n<p>Tair\u6301\u4e45\u5185\u5b58\u7248\u5e76\u4e0d\u662f\u7b80\u5355\u5c06Redis\u4e2d\u7684\u6570\u636e\u6362\u4e86\u4e00\u4e2a\u4ecb\u8d28\u5b58\u50a8\uff0c\u56e0\u4e3a\u8fd9\u6837\u4ec5\u80fd\u901a\u8fc7AEP\u964d\u4f4e\u6210\u672c\uff0c\u4f46\u6ca1\u7528\u5230AEP\u65ad\u7535\u6570\u636e\u4e0d\u4e22\u5931\u7684\u7279\u6027\uff0c\u5bf9\u6301\u4e45\u5316\u80fd\u529b\u6ca1\u6709\u4efb\u4f55\u63d0\u5347\u3002<\/p>\n<p>\u5f00\u6e90Redis\u901a\u8fc7\u5728\u78c1\u76d8\u4e0a\u8bb0\u5f55AppendOnlyLog\u6765\u6301\u4e45\u5316\u6570\u636e\uff0cAppendOnlyLog\u8bb0\u5f55\u4e86\u6240\u6709\u7684\u5199\u64cd\u4f5c\uff0c\u76f8\u5f53\u4e8eredolog\uff0c\u5728\u5b95\u673a\u6062\u590d\u65f6\u901a\u8fc7\u56de\u653e\u8fd9\u4e9blog\u6062\u590d\u6570\u636e\u3002\u4f46\u53d7\u9650\u4e8e\u78c1\u76d8\u4ecb\u8d28\u7684\u9ad8\u5ef6\u65f6\u548cRedis\u5185\u5b58\u6570\u636e\u5e93\u4f7f\u7528\u573a\u666f\u4e0b\u5bf9\u4f4e\u5ef6\u65f6\u7684\u8981\u6c42\uff0c\u5e76\u4e0d\u80fd\u5728\u6bcf\u6b21\u5199\u64cd\u4f5c\u540efsync\u6301\u4e45\u5316log\uff0c\u6700\u65b0\u5199\u5165\u7684\u6570\u636e\u53ef\u80fd\u5e76\u6ca1\u6709\u6301\u4e45\u5316\u5230\u78c1\u76d8\uff0c\u8fd9\u4e5f\u662f\u6570\u636e\u53ef\u80fd\u4e22\u5931\u7684\u6839\u56e0\u3002<\/p>\n<p>Tair\u6301\u4e45\u5185\u5b58\u7248\u7684\u6570\u636e\u6062\u590d\u6ca1\u6709\u4f7f\u7528AppendOnlyLog\u6765\u5b8c\u6210\uff0c \u800c\u662f\u5c06\u5c06redis\u6570\u636e\u7ed3\u6784\u5b58\u50a8\u5728AEP\u4e0a\uff0c\u8fd9\u6837\u5b95\u673a\u540e\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\u5e76\u4e0d\u4f1a\u4e22\u5931\uff0c\u5e76\u4e14\u5bf9\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\u589e\u52a0\u4e86\u4e00\u4e9b\u989d\u5916\u7684\u63cf\u8ff0\u4fe1\u606f\uff0c\u5b95\u673a\u540e\u5728recovery\u65f6\u80fd\u591f\u8bfb\u5230\u8fd9\u4e9b\u989d\u5916\u7684\u63cf\u8ff0\u4fe1\u606f\uff0c\u8ba9\u8fd9\u4e9bredis\u6570\u636e\u7ed3\u6784\u91cd\u65b0\u88ab\u8bc6\u522b\u548c\u7d22\u5f15\uff0c\u5c06\u72b6\u6001\u6062\u590d\u5230\u5b95\u673a\u524d\u7684\u6837\u5b50\u3002Tair\u901a\u8fc7\u5c06redis\u6570\u636e\u7ed3\u6784\u548c\u63cf\u8ff0\u4fe1\u606f\u5b9e\u65f6\u5199\u5165AEP\uff0c\u4fdd\u8bc1\u4e86\u5199\u5165\u6570\u636e\u7684\u5b9e\u65f6\u6301\u4e45\u5316\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342363eddeaf3a9dc.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p><strong>HA\u6570\u636e\u4e0d\u4e22\u5931<\/strong><\/p>\n<p>Tair\u6301\u4e45\u5185\u5b58\u7248\u4fdd\u8bc1\u4e86\u6570\u636e\u7684\u6301\u4e45\u5316\uff0c\u4f46\u751f\u4ea7\u73af\u5883\u4e2d\u90fd\u662f\u9ad8\u53ef\u7528\u67b6\u6784\uff0c\u591a\u6570\u60c5\u51b5\u4e0b\u5f53\u4e3b\u8282\u70b9\u5f02\u5e38\u5b95\u673a\u540e\u5e76\u4e0d\u4f1a\u7b49\u4e3b\u8282\u70b9\u91cd\u542f\u6062\u590d\uff0c\u800c\u662f\u5207\u6362\u5230\u5907\u8282\u70b9\u7ee7\u7eed\u63d0\u4f9b\u670d\u52a1\uff0c\u7136\u540e\u7ed9\u65b0\u7684\u4e3b\u8282\u70b9\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5907\u8282\u70b9\u3002\u6240\u4ee5\u5728\u6545\u969c\u53d1\u751f\u65f6\u5982\u679c\u6709\u6570\u636e\u8fd8\u6ca1\u4ece\u4e3b\u8282\u70b9\u540c\u6b65\u5230\u5907\u8282\u70b9\uff0c\u8fd9\u90e8\u5206\u6570\u636e\u5c31\u4f1a\u4e22\u5931\u3002<\/p>\n<p>Redis\u91c7\u7528\u7684\u5f02\u6b65\u540c\u6b65\uff0c\u5f53\u5ba2\u6237\u7aef\u5199\u5165\u6570\u636e\u5e76\u8fd4\u56de\u6210\u529f\u65f6\u5bf9Redis\u7684\u4fee\u6539\u53ef\u80fd\u8fd8\u6ca1\u540c\u6b65\u5230\u5907\u8282\u70b9\uff0c\u5982\u679c\u6b64\u65f6\u4e3b\u8282\u70b9\u5b95\u673a\u6570\u636e\u5c31\u4f1a\u4e22\u5931\u3002\u4e3a\u4e86\u907f\u514d\u5728HA\u8fc7\u7a0b\u4e2d\u6570\u636e\u4e22\u5931\uff0cTair\u6301\u4e45\u5185\u5b58\u7248\u5f15\u5165\u4e86\u534a\u540c\u6b65\u673a\u5236\uff0c\u786e\u4fdd\u5199\u5165\u8bf7\u6c42\u8fd4\u56de\u6210\u529f\u524d\u76f8\u5173\u7684\u4fee\u6539\u5df2\u7ecf\u540c\u6b65\u5230\u5907\u8282\u70b9\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230216\/167653342363eddeaf77824.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p>\u53ef\u4ee5\u53d1\u73b0\u5f00\u542f\u534a\u540c\u6b65\u529f\u80fd\u540e\u5199\u5165\u8bf7\u6c42\u7684RT\u4f1a\u53d8\u9ad8\uff0c\u591a\u51fa\u4e3b\u5907\u540c\u6b65\u7684\u8017\u65f6\uff0c\u8fd9\u90e8\u5206\u8017\u65f6\u5927\u6982\u5728\u51e0\u5341\u5fae\u79d2\u3002\u4f46\u901a\u8fc7\u4e00\u4e9b\u5f02\u6b65\u5316\u7684\u6280\u672f\uff0c\u867d\u7136\u5199\u8bf7\u6c42\u7684RT\u4f1a\u53d8\u9ad8\uff0c\u4f46\u5bf9\u5b9e\u4f8b\u7684\u6700\u5927\u5199\u541e\u5410\u5f71\u54cd\u5f88\u5c0f\u3002<\/p>\n<p>\u5f53\u5f00\u542f\u534a\u540c\u6b65\u540e\u751f\u6210\u8005\u901a\u8fc7xadd\u6295\u9012\u6d88\u606f\uff0c\u5982\u679c\u8fd4\u56de\u6210\u529f\uff0c\u6d88\u606f\u4e00\u5b9a\u540c\u6b65\u5230\u5907\u8282\u70b9\uff0c\u6b64\u65f6\u53d1\u751fHA\uff0c\u6d88\u8d39\u8005\u4e5f\u80fd\u5728\u5907\u8282\u70b9\u4e0a\u8bfb\u5230\u8fd9\u6761\u6d88\u606f\u3002\u5982\u679cxadd\u8bf7\u6c42\u8d85\u65f6\uff0c\u6b64\u65f6\u6d88\u606f\u53ef\u80fd\u540c\u6b65\u5230\u5907\u8282\u70b9\u4e5f\u53ef\u80fd\u6ca1\u6709\uff0c\u751f\u4ea7\u8005\u6ca1\u6cd5\u786e\u5b9a\uff0c\u6b64\u65f6\u901a\u8fc7\u518d\u6b21\u6295\u9012\u6d88\u606f\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u8be5\u6d88\u606f\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21\u3002\u5982\u679c\u8981\u4e25\u683c\u4fdd\u8bc1\u6d88\u606f\u4ec5\u88ab\u6d88\u8d39\u4e00\u6b21\uff0c\u90a3\u4e48\u751f\u4ea7\u8005\u53ef\u4ee5\u901a\u8fc7xread\u63a5\u53e3\u67e5\u8be2\u6d88\u606f\u662f\u5426\u5b58\u5728\uff0c\u5bf9\u4e8e\u4e0d\u5b58\u5728\u7684\u573a\u666f\u91cd\u65b0\u6295\u9012\u3002<\/p>\n<h4>2.\u603b\u7ed3<\/h4>\n<p><strong>\u4f18\u52bf<\/strong><\/p>\n<ul>\n<li>\u5f15\u5165\u4e86AEP\u4f5c\u4e3a\u5b58\u50a8\u4ecb\u8d28\uff0c\u76ee\u524dTair\u6301\u4e45\u5185\u5b58\u7248\u4ef7\u683c\u662f\u793e\u533a\u7248\u768470%\u3002<\/li>\n<li>\u4fdd\u8bc1\u4e86\u6570\u636e\u7684\u5b9e\u65f6\u6301\u4e45\u5316\uff0c\u5e76\u4e14\u901a\u8fc7\u534a\u540c\u6b65\u6280\u672f\u4fdd\u8bc1\u4e86HA\u4e0d\u4e22\u6570\u636e\uff0c\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u505a\u5230\u6d88\u606f\u4e0d\u4e22\u5931(\u5907\u5e93\u6545\u969c\u6216\u4e3b\u5907\u7f51\u7edc\u5f02\u5e38\u65f6\u4f1a\u964d\u7ea7\u4e3a\u5f02\u6b65\u540c\u6b65\uff0c\u4f18\u5148\u4fdd\u969c\u53ef\u7528\u6027)\uff0c\u6d88\u606f\u81f3\u5c11\u88ab\u6d88\u8d39\u4e00\u6b21\u6216\u4ec5\u88ab\u6d88\u8d39\u4e00\u6b21\u3002<\/li>\n<\/ul>\n<h3>\u4e94\u3001\u672a\u6765<\/h3>\n<p>\u6d88\u606f\u961f\u5217\u4e3b\u8981\u662f\u4e3a\u4e86\u89e3\u51b33\u7c7b\u95ee\u9898\uff0c\u5e94\u7528\u6a21\u5757\u7684\u89e3\u8026\u3001\u6d88\u606f\u7684\u5f02\u6b65\u5316\u3001\u524a\u5cf0\u586b\u8c37\u3002\u76ee\u524d\u4e3b\u6d41\u7684\u6d88\u606f\u961f\u5217\u90fd\u80fd\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff0c\u6240\u4ee5\u5728\u5b9e\u9645\u9009\u578b\u65f6\u8fd8\u4f1a\u8003\u8651\u4e00\u4e9b\u7279\u6b8a\u7684\u529f\u80fd\u662f\u5426\u6ee1\u8db3\uff0c\u4ea7\u54c1\u7684\u6027\u80fd\u5982\u4f55\uff0c\u5177\u4f53\u4e1a\u52a1\u573a\u666f\u4e0b\u7684\u6210\u672c\u600e\u4e48\u6837\uff0c\u5f00\u53d1\u7684\u590d\u6742\u5ea6\u7b49\u3002<\/p>\n<p>Redis\u7684\u6d88\u606f\u961f\u5217\u529f\u80fd\u5e76\u4e0d\u662f\u6700\u5168\u9762\u7684\uff0c\u5b83\u4e0d\u5e0c\u671b\u505a\u6210\u4e00\u4e2a\u5927\u800c\u5168\u7684\u4ea7\u54c1\uff0c\u800c\u662f\u505a\u4e00\u4e2a\u5c0f\u800c\u7f8e\u7684\u4ea7\u54c1\uff0c\u670d\u52a1\u597d\u4e00\u90e8\u5206\u7528\u6237\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u7684\u9700\u6c42\u3002\u76ee\u524d\u7528\u6237\u9009\u578bRedis\u4f5c\u4e3a\u6d88\u606f\u961f\u5217\u670d\u52a1\u7684\u539f\u56e0\uff0c\u4e3b\u8981\u6709Redis\u5728\u76f8\u540c\u6210\u672c\u4e0b\u541e\u5410\u66f4\u9ad8\u3001Redis\u7684\u5ef6\u65f6\u66f4\u4f4e\u3001\u5e94\u7528\u9700\u8981\u4e00\u4e2a\u6d88\u606f\u670d\u52a1\u4f46\u53c8\u4e0d\u60f3\u989d\u5916\u5f15\u5165\u4e00\u5806\u4f9d\u8d56\u7b49\u3002<\/p>\n<p>\u672a\u6765Tair\u6301\u4e45\u5185\u5b58\u7248\u4f1a\u9488\u5bf9\u8fd9\u4e9b\u8ff0\u6c42\uff0c\u628a\u8fd9\u4e9b\u4f18\u52bf\u7ee7\u7eed\u653e\u5927\u3002<\/p>\n<p><strong>\u541e\u5410<\/strong><\/p>\n<p>\u901a\u8fc7\u4f18\u5316\u6301\u4e45\u5185\u5b58\u7248\u7684\u6301\u4e45\u5316\u6d41\u7a0b\uff0c\u8ba9\u541e\u5410\u63a5\u8fd1\u5185\u5b58\u7248\u751a\u81f3\u8d85\u8fc7\u5185\u5b58\u7248\u541e\u5410\u3002<\/p>\n<p><strong>\u5ef6\u65f6<\/strong><\/p>\n<p>\u901a\u8fc7rdma\u5728\u591a\u526f\u672c\u95f4\u540c\u6b65\u6570\u636e\uff0c\u964d\u4f4e\u534a\u540c\u6b65\u4e0b\u5199\u5165\u6570\u636e\u7684\u5ef6\u65f6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis\u6d88\u606f\u961f\u5217\u53d1\u5c55\u5386\u7a0b \u6536\u85cf&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-201496","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201496","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=201496"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201496\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=201496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=201496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=201496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}