{"id":21577,"date":"2024-01-02T11:47:25","date_gmt":"2024-01-02T11:47:25","guid":{"rendered":"https:\/\/server.hk\/blog\/21577\/"},"modified":"2024-11-14T10:30:28","modified_gmt":"2024-11-14T02:30:28","slug":"mongodb-glossary-read-concern","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21577\/","title":{"rendered":"MongoDB \u8a5e\u5f59\u8868 &#8211; \u8b80\u53d6\u95dc\u6ce8\u5ea6"},"content":{"rendered":"<h1 id=\"mongodb-glossary-read-concern-sonCLTDpLG\">MongoDB \u8a5e\u5f59\u8868 &#8211; \u8b80\u53d6\u95dc\u6ce8\u5ea6\uff08Read Concern\uff09<\/h1>\n<p>\u5728\u8cc7\u6599\u5eab\u7684\u4e16\u754c\u4e2d\uff0cMongoDB \u56e0\u5176\u9748\u6d3b\u6027\u3001\u53ef\u64f4\u5c55\u6027\u548c\u9ad8\u6548\u80fd\u800c\u6210\u70ba\u4e86\u53d7\u6b61\u8fce\u7684\u9078\u64c7\u3002\u4f5c\u70ba\u4e00\u500b NoSQL \u8cc7\u6599\u5eab\uff0cMongoDB \u63d0\u4f9b\u4e86\u591a\u7a2e\u529f\u80fd\uff0c\u4ee5\u6eff\u8db3\u73fe\u4ee3\u61c9\u7528\u7a0b\u5f0f\u7684\u9700\u6c42\u3002\u5176\u4e2d\u4e00\u500b\u529f\u80fd\u4fbf\u662f\u300c\u8b80\u53d6\u95dc\u6ce8\u5ea6\u300d(Read Concern)\u3002<\/p>\n<h2 id=\"understanding-read-concern-sonCLTDpLG\">\u4e86\u89e3\u8b80\u53d6\u95dc\u6ce8\u5ea6<\/h2>\n<p>MongoDB \u7684\u8b80\u53d6\u95dc\u6ce8\u5ea6\u6307\u7684\u662f\u8b80\u53d6\u64cd\u4f5c\u6240\u4fdd\u8b49\u7684\u8cc7\u6599\u4e00\u81f4\u6027\u5c64\u7d1a\u3002\u5b83\u8b93\u958b\u767c\u8005\u80fd\u5920\u63a7\u5236\u5728 MongoDB \u8907\u672c\u96c6\u6216\u5206\u7247\u96c6\u7fa4\u4e2d\u7684\u591a\u6b21\u8b80\u53d6\u64cd\u4f5c\u4e2d\uff0c\u8cc7\u6599\u8b8a\u66f4\u7684\u53ef\u898b\u6027\u3002<\/p>\n<p>\u9810\u8a2d\u60c5\u6cc1\u4e0b\uff0cMongoDB \u4f7f\u7528\u300clocal\u300d\u8b80\u53d6\u95dc\u6ce8\u5ea6\uff0c\u9019\u63d0\u4f9b\u4e86\u300c\u8b80\u53d6\u81ea\u5df1\u7684\u5beb\u5165\u300d\u4e00\u81f4\u6027\u3002\u9019\u610f\u5473\u8457\u8b80\u53d6\u64cd\u4f5c\u5c07\u8fd4\u56de\u4f86\u81ea\u4e3b\u8907\u672c\u96c6\u6210\u54e1\u6216\u5206\u7247\u4e2d\u6700\u65b0\u63d0\u4ea4\u7684\u8cc7\u6599\uff0c\u4f46\u5b83\u4e0d\u4fdd\u8b49\u8cc7\u6599\u5728\u6574\u500b\u8907\u672c\u96c6\u6216\u5206\u7247\u96c6\u7fa4\u4e2d\u7684\u6700\u65b0\u72c0\u614b\u3002<\/p>\n<p>\u958b\u767c\u8005\u53ef\u4ee5\u6839\u64da\u61c9\u7528\u7a0b\u5f0f\u7684\u9700\u6c42\uff0c\u9078\u64c7\u4e0d\u540c\u5c64\u7d1a\u7684\u8b80\u53d6\u95dc\u6ce8\u5ea6\uff1a<\/p>\n<ul>\n<li><strong>local:<\/strong> \u9019\u662f\u9810\u8a2d\u7684\u8b80\u53d6\u95dc\u6ce8\u5ea6\uff0c\u63d0\u4f9b\u6700\u4f4e\u5c64\u7d1a\u7684\u4e00\u81f4\u6027\u3002\u5b83\u4fdd\u8b49\u8b80\u53d6\u64cd\u4f5c\u6703\u8fd4\u56de\u4f86\u81ea\u4e3b\u8907\u672c\u96c6\u6210\u54e1\u6216\u5206\u7247\u4e2d\u6700\u65b0\u63d0\u4ea4\u7684\u8cc7\u6599\u3002<\/li>\n<li><strong>available:<\/strong> \u6b64\u8b80\u53d6\u95dc\u6ce8\u5ea6\u4fdd\u8b49\u8b80\u53d6\u64cd\u4f5c\u6703\u8fd4\u56de\u4f86\u81ea\u6700\u8fd1\u7684\u8907\u672c\u96c6\u6210\u54e1\u6216\u5206\u7247\u4e2d\u53ef\u7528\u7684\u8cc7\u6599\u3002\u5b83\u4e0d\u6703\u7b49\u5f85\u8cc7\u6599\u8907\u88fd\u5230\u8907\u672c\u96c6\u6216\u5206\u7247\u96c6\u7fa4\u7684\u6240\u6709\u6210\u54e1\u3002<\/li>\n<li><strong>majority:<\/strong> \u6b64\u8b80\u53d6\u95dc\u6ce8\u5ea6\u4fdd\u8b49\u8b80\u53d6\u64cd\u4f5c\u8fd4\u56de\u5df2\u88ab\u5927\u591a\u6578\u8907\u672c\u96c6\u6210\u54e1\u6216\u5206\u7247\u78ba\u8a8d\u7684\u8cc7\u6599\u3002\u5b83\u63d0\u4f9b\u5f37\u4e00\u81f4\u6027\uff0c\u4f46\u53ef\u80fd\u6703\u5f15\u5165\u984d\u5916\u7684\u5ef6\u9072\u3002<\/li>\n<li><strong>linearizable:<\/strong> \u6b64\u8b80\u53d6\u95dc\u6ce8\u5ea6\u4fdd\u8b49\u7dda\u6027\u5316\uff0c\u5373\u8b80\u53d6\u64cd\u4f5c\u6703\u8fd4\u56de\u53cd\u6620\u6240\u6709\u5728\u8b80\u53d6\u64cd\u4f5c\u958b\u59cb\u524d\u5df2\u6210\u529f\u5b8c\u6210\u5beb\u5165\u7684\u8cc7\u6599\u3002\u5b83\u63d0\u4f9b\u6700\u9ad8\u5c64\u7d1a\u7684\u4e00\u81f4\u6027\uff0c\u4f46\u53ef\u80fd\u6703\u5f71\u97ff\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"use-cases-for-read-concern-sonCLTDpLG\">\u8b80\u53d6\u95dc\u6ce8\u5ea6\u7684\u4f7f\u7528\u60c5\u666f<\/h2>\n<p>\u8b80\u53d6\u95dc\u6ce8\u5ea6\u7684\u9078\u64c7\u53d6\u6c7a\u65bc\u5177\u9ad4\u7684\u4f7f\u7528\u60c5\u666f\u53ca\u6240\u9700\u7684\u4e00\u81f4\u6027\u5c64\u7d1a\u3002\u8b93\u6211\u5011\u63a2\u8a0e\u4e00\u4e9b\u4e0d\u540c\u8b80\u53d6\u95dc\u6ce8\u5ea6\u6709\u7528\u7684\u60c5\u666f\uff1a<\/p>\n<h3 id=\"1-real-time-analytics-sonCLTDpLG\">1. \u5be6\u6642\u5206\u6790<\/h3>\n<p>\u5728\u5be6\u6642\u5206\u6790\u61c9\u7528\u7a0b\u5f0f\u4e2d\uff0c\u7372\u53d6\u6700\u65b0\u7684\u6578\u64da\u9032\u884c\u5206\u6790\u81f3\u95dc\u91cd\u8981\u3002\u5728\u9019\u7a2e\u60c5\u6cc1\u4e0b\uff0c\u4f7f\u7528\u300clinearizable\u300d\u8b80\u53d6\u95dc\u6ce8\u5ea6\u53ef\u4ee5\u78ba\u4fdd\u8b80\u53d6\u64cd\u4f5c\u53cd\u6620\u6240\u6709\u6700\u65b0\u7684\u5beb\u5165\uff0c\u5f9e\u800c\u63d0\u4f9b\u6e96\u78ba\u4e14\u4e00\u81f4\u7684\u7d50\u679c\u3002<\/p>\n<h3 id=\"2-high-availability-sonCLTDpLG\">2. \u9ad8\u53ef\u7528\u6027<\/h3>\n<p>\u5728\u9ad8\u53ef\u7528\u6027\u70ba\u91cd\u9ede\u7684\u5834\u666f\u4e2d\uff0c\u4f7f\u7528\u300cavailable\u300d\u8b80\u53d6\u95dc\u6ce8\u5ea6\u5141\u8a31\u61c9\u7528\u7a0b\u5f0f\u5f9e\u6700\u8fd1\u7684\u8907\u672c\u96c6\u6210\u54e1\u6216\u5206\u7247\u4e2d\u8b80\u53d6\u8cc7\u6599\uff0c\u5373\u4f7f\u8a72\u8cc7\u6599\u672a\u5b8c\u5168\u8907\u88fd\u5230\u6574\u500b\u96c6\u7fa4\u3002\u9019\u78ba\u4fdd\u4e86\u61c9\u7528\u7a0b\u5f0f\u5728\u7db2\u7d61\u5206\u5340\u6216\u8907\u672c\u96c6\u91cd\u65b0\u914d\u7f6e\u671f\u9593\u4ecd\u80fd\u4fdd\u6301\u56de\u61c9\u3002<\/p>\n<h3 id=\"3-financial-transactions-sonCLTDpLG\">3. \u91d1\u878d\u4ea4\u6613<\/h3>\n<p>\u5c0d\u65bc\u9700\u8981\u5f37\u4e00\u81f4\u6027\u7684\u91d1\u878d\u61c9\u7528\u7a0b\u5f0f\uff0c\u300cmajority\u300d\u8b80\u53d6\u95dc\u6ce8\u5ea6\u662f\u5408\u9069\u7684\u9078\u64c7\u3002\u5b83\u78ba\u4fdd\u8b80\u53d6\u64cd\u4f5c\u8fd4\u56de\u5df2\u88ab\u5927\u591a\u6578\u8907\u672c\u96c6\u6210\u54e1\u6216\u5206\u7247\u78ba\u8a8d\u7684\u8cc7\u6599\uff0c\u6e1b\u5c11\u4e86\u4e0d\u4e00\u81f4\u6216\u904e\u6642\u8cc7\u6599\u7684\u98a8\u96aa\u3002<\/p>\n<h2 id=\"conclusion-sonCLTDpLG\">\u7d50\u8ad6<\/h2>\n<p>MongoDB \u7684\u8b80\u53d6\u95dc\u6ce8\u5ea6\u8b93\u958b\u767c\u8005\u80fd\u5920\u9748\u6d3b\u9078\u64c7\u6700\u9069\u5408\u5176\u61c9\u7528\u7a0b\u5f0f\u9700\u6c42\u7684\u8cc7\u6599\u4e00\u81f4\u6027\u5c64\u7d1a\u3002\u7121\u8ad6\u662f\u5be6\u6642\u5206\u6790\u3001\u9ad8\u53ef\u7528\u6027\u9084\u662f\u91d1\u878d\u4ea4\u6613\uff0cMongoDB \u63d0\u4f9b\u4e86\u4e0d\u540c\u7684\u8b80\u53d6\u95dc\u6ce8\u5ea6\uff0c\u4ee5\u78ba\u4fdd\u6240\u9700\u7684\u4e00\u81f4\u6027\u548c\u6548\u80fd\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc MongoDB \u53ca\u5176\u529f\u80fd\u7684\u8cc7\u8a0a\uff0c\u8acb\u8003\u616e\u63a2\u7d22 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u9019\u662f\u4e00\u5bb6\u5c08\u6ce8\u65bc MongoDB \u8a17\u7ba1\u89e3\u6c7a\u65b9\u6848\u7684\u9818\u5148 VPS \u8a17\u7ba1\u516c\u53f8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB \u8a5e\u5f59\u8868 &#038;#82&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-21577","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21577","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=21577"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21577\/revisions"}],"predecessor-version":[{"id":23869,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21577\/revisions\/23869"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}