{"id":6540,"date":"2024-09-11T14:52:22","date_gmt":"2024-09-11T06:52:22","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6540"},"modified":"2024-09-11T14:58:16","modified_gmt":"2024-09-11T06:58:16","slug":"%e5%90%8e%e7%ab%af%e5%bc%80%e5%8f%91%e8%a7%84%e8%8c%83%e7%b3%bb%e5%88%97","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6540","title":{"rendered":"\u540e\u7aef\u5f00\u53d1\u89c4\u8303\u7cfb\u5217"},"content":{"rendered":"<p>API \u8bbe\u8ba1\u6307\u5357\uff1a<a href=\"https:\/\/cloud.google.com\/apis\/design?hl=zh-cn\">https:\/\/cloud.google.com\/apis\/design?hl=zh-cn<\/a><br \/>\n\u6570\u636e\u5e93\u8bbe\u8ba1\u89c4\u8303\uff1a<a href=\"https:\/\/developer.aliyun.com\/article\/709387\">https:\/\/developer.aliyun.com\/article\/709387<\/a><br \/>\nRedis Key \u547d\u4ee4\u89c4\u8303\uff1a\u53c2\u8003\u4e0b\u65b9<br \/>\nUber Go \u7f16\u7801\u89c4\u8303\uff1a<a href=\"https:\/\/github.com\/xxjwxc\/uber_go_guide_cn\">https:\/\/github.com\/xxjwxc\/uber_go_guide_cn<\/a><\/p>\n<h2>Redis Key \u547d\u540d\u89c4\u8303<\/h2>\n<p>Redis \u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u6027\u80fd\u7684\u952e\u503c\u6570\u636e\u5e93\uff0c\u5176 Key \u7684\u547d\u540d\u89c4\u8303\u5bf9\u6027\u80fd\u3001\u53ef\u8bfb\u6027\u4ee5\u53ca\u6570\u636e\u7ba1\u7406\u90fd\u6709\u7740\u91cd\u8981\u7684\u5f71\u54cd\u3002\u4e00\u4e2a\u597d\u7684\u547d\u540d\u89c4\u8303\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ec4\u7ec7\u6570\u636e\uff0c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\uff0c\u51cf\u5c11\u51fa\u9519\u7684\u6982\u7387\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u8981\u6709 Key \u547d\u540d\u89c4\u8303\uff1f<\/h3>\n<ul>\n<li><strong>\u63d0\u9ad8\u53ef\u8bfb\u6027\uff1a<\/strong> \u6e05\u6670\u7684\u547d\u540d\u6709\u52a9\u4e8e\u5feb\u901f\u7406\u89e3 Key \u7684\u542b\u4e49\uff0c\u65b9\u4fbf\u7ef4\u62a4\u548c\u8c03\u8bd5\u3002<\/li>\n<li><strong>\u65b9\u4fbf\u7ba1\u7406\uff1a<\/strong> \u89c4\u8303\u7684\u547d\u540d\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ec4\u7ec7\u6570\u636e\uff0c\u63d0\u9ad8\u6570\u636e\u68c0\u7d22\u6548\u7387\u3002<\/li>\n<li><strong>\u907f\u514d\u51b2\u7a81\uff1a<\/strong> \u7edf\u4e00\u7684\u547d\u540d\u89c4\u8303\u53ef\u4ee5\u51cf\u5c11 Key \u51b2\u7a81\u7684\u6982\u7387\uff0c\u4fdd\u8bc1\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002<\/li>\n<\/ul>\n<h3>Redis Key \u547d\u540d\u89c4\u8303\u5efa\u8bae<\/h3>\n<ol>\n<li>\n<p><strong>\u91c7\u7528\u547d\u540d\u7a7a\u95f4\uff1a<\/strong><\/p>\n<ul>\n<li>\u4e0d\u540c\u7684\u4e1a\u52a1\u6a21\u5757\u6216\u6570\u636e\u7c7b\u578b\u4f7f\u7528\u4e0d\u540c\u7684\u524d\u7f00\u3002\u4f8b\u5982\uff1a\n<ul>\n<li><code>user:info:userId<\/code>\uff1a\u8868\u793a\u7528\u6237\u7684\u4fe1\u606f<\/li>\n<li><code>product:detail:productId<\/code>\uff1a\u8868\u793a\u5546\u54c1\u7684\u8be6\u7ec6\u4fe1\u606f<\/li>\n<\/ul>\n<\/li>\n<li>\u547d\u540d\u7a7a\u95f4\u53ef\u4ee5\u6709\u6548\u5730\u907f\u514d Key \u51b2\u7a81\uff0c\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u6709\u610f\u4e49\u7684\u540d\u79f0\uff1a<\/strong><\/p>\n<ul>\n<li>Key \u7684\u540d\u79f0\u5e94\u8be5\u80fd\u591f\u76f4\u89c2\u5730\u53cd\u6620\u51fa\u5b58\u50a8\u7684\u6570\u636e\u7684\u542b\u4e49\u3002<\/li>\n<li>\u907f\u514d\u4f7f\u7528\u8fc7\u4e8e\u7b80\u77ed\u6216\u6a21\u7cca\u7684\u540d\u79f0\u3002<\/li>\n<li>\u4f8b\u5982\uff1a<code>user_id<\/code> \u6bd4 <code>u<\/code> \u66f4\u5177\u6709\u53ef\u8bfb\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u4e0b\u5212\u7ebf\u6216\u5192\u53f7\u5206\u9694\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4e0b\u5212\u7ebf\uff08_\uff09\u6216\u5192\u53f7\uff08:\uff09\u6765\u5206\u9694\u4e0d\u540c\u7684\u5355\u8bcd\uff0c\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002<\/li>\n<li>\u4f8b\u5982\uff1a<code>user_profile<\/code> \u6216 <code>user:profile<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u907f\u514d\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\uff1a<\/strong><\/p>\n<ul>\n<li>\u9664\u4e86\u4e0b\u5212\u7ebf\u6216\u5192\u53f7\uff0c\u5c3d\u91cf\u907f\u514d\u4f7f\u7528\u5176\u4ed6\u7279\u6b8a\u5b57\u7b26\uff0c\u4ee5\u514d\u5f15\u8d77\u6b67\u4e49\u6216\u9519\u8bef\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4fdd\u6301\u4e00\u81f4\u6027\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u6574\u4e2a\u9879\u76ee\u4e2d\u4fdd\u6301\u4e00\u81f4\u7684\u547d\u540d\u98ce\u683c\uff0c\u6709\u5229\u4e8e\u56e2\u961f\u534f\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u5e38\u89c1\u7684\u547d\u540d\u65b9\u5f0f<\/h3>\n<ul>\n<li><strong>\u4e1a\u52a1\u6a21\u5757\u540d:\u4e1a\u52a1\u903b\u8f91\u542b\u4e49:\u5176\u4ed6:value\u7c7b\u578b<\/strong>\n<ul>\n<li>\u4f8b\u5982\uff1a<code>order:detail:123:json<\/code> \u8868\u793a\u8ba2\u5355123\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u6570\u636e\u7c7b\u578b\u4e3a JSON\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u9879\u76ee\u540d:\u6a21\u5757\u540d:\u5b50\u6a21\u5757\u540d:\u4e1a\u52a1\u5bf9\u8c61:\u4e1a\u52a1\u5c5e\u6027<\/strong>\n<ul>\n<li>\u4f8b\u5982\uff1a<code>myapp:user:profile:username:zhangsan<\/code> \u8868\u793amyapp\u9879\u76ee\u4e2d\u7528\u6237\u6a21\u5757\u7684profile\u5b50\u6a21\u5757\u4e2d\uff0c\u7528\u6237\u540d\u4e3azhangsan\u7684\u7528\u6237\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u547d\u540d\u793a\u4f8b<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u573a\u666f<\/th>\n<th>\u793a\u4f8b Key<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u7528\u6237\u4fe1\u606f<\/td>\n<td>user:info:123<\/td>\n<td>\u7528\u6237ID\u4e3a123\u7684\u7528\u6237\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>\u5546\u54c1\u5e93\u5b58<\/td>\n<td>product:stock:iphone14<\/td>\n<td>iPhone14\u7684\u5e93\u5b58\u6570\u91cf<\/td>\n<\/tr>\n<tr>\n<td>\u7528\u6237\u8bbf\u95ee\u8bb0\u5f55<\/td>\n<td>user:visit:123:20230101<\/td>\n<td>\u7528\u6237ID\u4e3a123\u57282023\u5e741\u67081\u65e5\u7684\u8bbf\u95ee\u8bb0\u5f55<\/td>\n<\/tr>\n<tr>\n<td>\u7f13\u5b58<\/td>\n<td>cache:user:123<\/td>\n<td>\u7f13\u5b58\u7528\u6237ID\u4e3a123\u7684\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>\u4efb\u52a1\u961f\u5217<\/td>\n<td>queue:task:process_order<\/td>\n<td>\u5904\u7406\u8ba2\u5355\u7684\u4efb\u52a1\u961f\u5217<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879<\/h3>\n<ul>\n<li><strong>Key \u957f\u5ea6\uff1a<\/strong> \u867d\u7136 Redis \u652f\u6301\u8f83\u957f\u7684 Key\uff0c\u4f46\u8fc7\u957f\u7684 Key \u4f1a\u5f71\u54cd\u6027\u80fd\u548c\u5185\u5b58\u5360\u7528\u3002\u5efa\u8bae Key \u7684\u957f\u5ea6\u4fdd\u6301\u5728\u5408\u7406\u8303\u56f4\u5185\u3002<\/li>\n<li><strong>Key \u8fc7\u671f\uff1a<\/strong> \u5bf9\u4e8e\u4e00\u4e9b\u4e34\u65f6\u6570\u636e\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\uff0c\u907f\u514d\u5360\u7528\u8fc7\u591a\u5185\u5b58\u3002<\/li>\n<li><strong>Key \u547d\u540d\u7a7a\u95f4\u9694\u79bb\uff1a<\/strong> \u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684 Redis \u5b9e\u4f8b\u6216\u4e0d\u540c\u7684\u547d\u540d\u7a7a\u95f4\u6765\u9694\u79bb\u4e0d\u540c\u4e1a\u52a1\u7684\u6570\u636e\u3002<\/li>\n<\/ul>\n<h3>\u603b\u7ed3<\/h3>\n<p>Redis Key \u7684\u547d\u540d\u89c4\u8303\u867d\u7136\u6ca1\u6709\u4e25\u683c\u7684\u6807\u51c6\uff0c\u4f46\u4e00\u4e2a\u597d\u7684\u547d\u540d\u89c4\u8303\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u7ef4\u62a4\u6027\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u7684\u9700\u6c42\u548c\u56e2\u961f\u7684\u4e60\u60ef\u6765\u5236\u5b9a\u9002\u5408\u81ea\u5df1\u7684\u547d\u540d\u89c4\u8303\u3002<\/p>\n<p><strong>\u5e0c\u671b\u4ee5\u4e0a\u5185\u5bb9\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff01<\/strong><\/p>\n<p><strong>\u60a8\u8fd8\u6709\u5176\u4ed6\u5173\u4e8e Redis Key \u547d\u540d\u89c4\u8303\u7684\u95ee\u9898\u5417\uff1f<\/strong> \u6bd4\u5982\uff1a<\/p>\n<ul>\n<li>\u5982\u4f55\u8bbe\u8ba1\u4e00\u4e2a\u9ad8\u6548\u7684\u547d\u540d\u7a7a\u95f4\uff1f<\/li>\n<li>\u5982\u4f55\u5904\u7406 Key \u8fc7\u671f\u7684\u95ee\u9898\uff1f<\/li>\n<li>\u5982\u4f55\u5728\u5927\u578b\u9879\u76ee\u4e2d\u4fdd\u8bc1\u547d\u540d\u7684\u4e00\u81f4\u6027\uff1f<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>API \u8bbe\u8ba1\u6307\u5357\uff1ahttps:\/\/cloud.google.com\/apis\/design?hl=zh-cn &#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6540\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[],"class_list":["post-6540","post","type-post","status-publish","format-standard","hentry","category-123"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6540"}],"version-history":[{"count":2,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6540\/revisions"}],"predecessor-version":[{"id":6542,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6540\/revisions\/6542"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}