{"id":10006290,"date":"2022-08-23T16:08:33","date_gmt":"2022-08-23T08:08:33","guid":{"rendered":"https:\/\/ityet.com\/?p=10006290"},"modified":"2022-08-23T16:08:33","modified_gmt":"2022-08-23T08:08:33","slug":"mysql%e5%92%8credis%e6%95%b0%e6%8d%ae%e5%a6%82%e4%bd%95%e4%bf%9d%e6%8c%81%e4%b8%80%e8%87%b4","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006290","title":{"rendered":"Mysql\u548cRedis\u6570\u636e\u5982\u4f55\u4fdd\u6301\u4e00\u81f4"},"content":{"rendered":"<p>\u5148\u9610\u660e\u4e00\u4e0b Mysql \u548c Redis \u7684\u5173\u7cfb\uff1aMysql \u662f\u6570\u636e\u5e93\uff0c\u7528\u6765\u6301\u4e45\u5316\u6570\u636e\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4fdd\u8bc1\u6570\u636e\u7684\u53ef\u9760\u6027\uff1bRedis \u662f\u7528\u6765\u5f53\u7f13\u5b58\uff0c\u7528\u6765\u63d0\u5347\u6570\u636e\u8bbf\u95ee\u7684\u6027\u80fd\u3002<\/p>\n<p>\u5173\u4e8e\u5982\u4f55\u4fdd\u8bc1 Mysql \u548c Redis \u4e2d\u7684\u6570\u636e\u4e00\u81f4\uff08\u5373\u7f13\u5b58\u4e00\u81f4\u6027\u95ee\u9898\uff09\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u7ecf\u5178\u7684\u95ee\u9898\u3002<\/p>\n<p>\u4f7f\u7528\u8fc7\u7f13\u5b58\u7684\u4eba\u90fd\u5e94\u8be5\u77e5\u9053\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u8981\u60f3\u5b9e\u65f6\u523b\u4fdd\u8bc1\u7f13\u5b58\u548c\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u4e00\u6837\uff0c\u5f88\u96be\u505a\u5230\u3002<\/p>\n<p>\u57fa\u672c\u4e0a\u90fd\u662f\u5c3d\u53ef\u80fd\u8ba9\u4ed6\u4eec\u7684\u6570\u636e\u5728\u7edd\u5927\u90e8\u5206\u65f6\u95f4\u5185\u4fdd\u6301\u4e00\u81f4\uff0c\u5e76\u4fdd\u8bc1\u6700\u7ec8\u662f\u4e00\u81f4\u7684\u3002<\/p>\n<p><strong>\u7f13\u5b58\u4e0d\u4e00\u81f4\u662f\u5982\u4f55\u4ea7\u751f\u7684<\/strong><\/p>\n<p>\u5982\u679c\u6570\u636e\u4e00\u76f4\u6ca1\u6709\u53d8\u66f4\uff0c\u90a3\u4e48\u5c31\u4e0d\u4f1a\u51fa\u73b0\u7f13\u5b58\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002<\/p>\n<p>\u901a\u5e38\u7f13\u5b58\u4e0d\u4e00\u81f4\u662f\u53d1\u751f\u5728\u6570\u636e\u6709\u53d8\u66f4\u7684\u65f6\u5019\u3002\u56e0\u4e3a\u6bcf\u6b21\u6570\u636e\u53d8\u66f4\u4f60\u9700\u8981\u540c\u65f6\u64cd\u4f5c\u6570\u636e\u5e93\u548c\u7f13\u5b58\uff0c\u800c\u4ed6\u4eec\u53c8\u5c5e\u4e8e\u4e0d\u540c\u7684\u7cfb\u7edf\uff0c\u65e0\u6cd5\u505a\u5230\u540c\u65f6\u64cd\u4f5c\u6210\u529f\u6216\u5931\u8d25\uff0c\u603b\u4f1a\u6709\u4e00\u4e2a\u65f6\u95f4\u5dee\u3002\u5728\u5e76\u53d1\u8bfb\u5199\u7684\u65f6\u5019\u53ef\u80fd\u5c31\u4f1a\u51fa\u73b0\u7f13\u5b58\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\uff08\u7406\u8bba\u4e0a\u901a\u8fc7\u5206\u5e03\u5f0f\u4e8b\u52a1\u53ef\u4ee5\u4fdd\u8bc1\u8fd9\u4e00\u70b9\uff0c\u4e0d\u8fc7\u5b9e\u9645\u4e0a\u57fa\u672c\u4e0a\u5f88\u5c11\u6709\u4eba\u8fd9\u4e48\u505a\uff09\u3002<\/p>\n<p>\u867d\u7136\u6ca1\u529e\u6cd5\u5728\u6570\u636e\u6709\u53d8\u66f4\u65f6\uff0c\u4fdd\u8bc1\u7f13\u5b58\u548c\u6570\u636e\u5e93\u5f3a\u4e00\u81f4\uff0c\u4f46\u5bf9\u7f13\u5b58\u7684\u66f4\u65b0\u8fd8\u662f\u6709\u4e00\u5b9a\u8bbe\u8ba1\u65b9\u6cd5\u7684\uff0c\u9075\u5faa\u8fd9\u4e9b\u8bbe\u8ba1\u65b9\u6cd5\uff0c\u80fd\u591f\u8ba9\u8fd9\u4e2a\u4e0d\u4e00\u81f4\u7684\u5f71\u54cd\u65f6\u95f4\u548c\u5f71\u54cd\u8303\u56f4\u6700\u5c0f\u5316\u3002<\/p>\n<p><strong>\u7f13\u5b58\u66f4\u65b0\u7684\u51e0\u79cd\u8bbe\u8ba1<\/strong><\/p>\n<p>\u7f13\u5b58\u66f4\u65b0\u7684\u8bbe\u8ba1\u65b9\u6cd5\u5927\u6982\u6709\u4ee5\u4e0b\u56db\u79cd\uff1a<\/p>\n<ul>\n<li>\u5148\u5220\u9664\u7f13\u5b58\uff0c\u518d\u66f4\u65b0\u6570\u636e\u5e93\uff08\u8fd9\u79cd\u65b9\u6cd5\u5728\u5e76\u53d1\u4e0b\u6700\u5bb9\u6613\u51fa\u73b0\u957f\u65f6\u95f4\u7684\u810f\u6570\u636e\uff0c\u4e0d\u53ef\u53d6\uff09<\/li>\n<li>\u5148\u66f4\u65b0\u6570\u636e\u5e93\uff0c\u5220\u9664\u7f13\u5b58\uff08Cache Aside Pattern\uff09<\/li>\n<li>\u53ea\u66f4\u65b0\u7f13\u5b58\uff0c\u7531\u7f13\u5b58\u81ea\u5df1\u540c\u6b65\u66f4\u65b0\u6570\u636e\u5e93\uff08Read\/Write Through Pattern\uff09<\/li>\n<li>\u53ea\u66f4\u65b0\u7f13\u5b58\uff0c\u7531\u7f13\u5b58\u81ea\u5df1\u5f02\u6b65\u66f4\u65b0\u6570\u636e\u5e93\uff08Write Behind Cache Pattern\uff09<\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e9b\u8fd9\u56db\u79cd\u8bbe\u8ba1\u65b9\u6cd5<br \/><strong>\u5148\u5220\u9664\u7f13\u5b58\uff0c\u518d\u66f4\u65b0\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u5728\u5e76\u53d1\u8bfb\u5199\u7684\u60c5\u51b5\u4e0b\u5bb9\u6613\u51fa\u73b0\u7f13\u5b58\u4e0d\u4e00\u81f4\u7684\u95ee\u9898<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042363255\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5176\u53ef\u80fd\u7684\u6267\u884c\u6d41\u7a0b\u987a\u5e8f\u4e3a\uff1a<br \/>\u5ba2\u6237\u7aef 1 \u89e6\u53d1\u66f4\u65b0\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 2 \u89e6\u53d1\u67e5\u8be2\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 1 \u5220\u9664\u7f13\u5b58\u4e2d\u6570\u636e A<br \/>\u5ba2\u6237\u7aef 2 \u67e5\u8be2\u7f13\u5b58\u4e2d\u6570\u636e A\uff0c\u672a\u547d\u4e2d<br \/>\u5ba2\u6237\u7aef 2 \u4ece\u6570\u636e\u5e93\u67e5\u8be2\u6570\u636e A\uff0c\u5e76\u66f4\u65b0\u5230\u7f13\u5b58\u4e2d<br \/>\u5ba2\u6237\u7aef 1 \u66f4\u65b0\u6570\u636e\u5e93\u4e2d\u6570\u636e A<\/p>\n<p>\u53ef\u89c1\uff0c\u6700\u540e\u7f13\u5b58\u4e2d\u7684\u6570\u636e A \u8ddf\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e A \u662f\u4e0d\u4e00\u81f4\u7684\uff0c\u7f13\u5b58\u4e2d\u7684\u6570\u636e A \u662f\u65e7\u7684\u810f\u6570\u636e\u3002<\/p>\n<p>\u56e0\u6b64\u4e00\u822c\u4e0d\u5efa\u8bae\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u3002<\/p>\n<p><strong>\u5148\u66f4\u65b0\u6570\u636e\u5e93\uff0c\u518d\u8ba9\u7f13\u5b58\u5931\u6548<\/strong><br \/>\u8fd9\u79cd\u65b9\u6cd5\u5728\u5e76\u53d1\u8bfb\u5199\u7684\u60c5\u51b5\u4e0b\uff0c\u4e5f\u53ef\u80fd\u4f1a\u51fa\u73b0\u77ed\u6682\u7f13\u5b58\u4e0d\u4e00\u81f4\u7684\u95ee\u9898<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042363256\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5176\u53ef\u80fd\u6267\u884c\u7684\u6d41\u7a0b\u987a\u5e8f\u4e3a\uff1a<br \/>\u5ba2\u6237\u7aef 1 \u89e6\u53d1\u66f4\u65b0\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 2 \u89e6\u53d1\u67e5\u8be2\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 3 \u89e6\u53d1\u67e5\u8be2\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 1 \u66f4\u65b0\u6570\u636e\u5e93\u4e2d\u6570\u636e A<br \/>\u5ba2\u6237\u7aef 2 \u67e5\u8be2\u7f13\u5b58\u4e2d\u6570\u636e A\uff0c\u547d\u4e2d\u8fd4\u56de\uff08\u65e7\u6570\u636e\uff09<br \/>\u5ba2\u6237\u7aef 1 \u8ba9\u7f13\u5b58\u4e2d\u6570\u636e A \u5931\u6548<br \/>\u5ba2\u6237\u7aef 3 \u67e5\u8be2\u7f13\u5b58\u4e2d\u6570\u636e A\uff0c\u672a\u547d\u4e2d<br \/>\u5ba2\u6237\u7aef 3 \u67e5\u8be2\u6570\u636e\u5e93\u4e2d\u6570\u636e A\uff0c\u5e76\u66f4\u65b0\u5230\u7f13\u5b58\u4e2d<\/p>\n<p>\u53ef\u89c1\uff0c\u6700\u540e\u7f13\u5b58\u4e2d\u7684\u6570\u636e A \u548c\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e A \u662f\u4e00\u81f4\u7684\uff0c\u7406\u8bba\u4e0a\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u5c0f\u6bb5\u65f6\u95f4\u6570\u636e\u4e0d\u4e00\u81f4\uff0c\u4e0d\u8fc7\u8fd9\u79cd\u6982\u7387\u4e5f\u6bd4\u8f83\u4f4e\uff0c\u5927\u90e8\u5206\u7684\u4e1a\u52a1\u4e5f\u4e0d\u4f1a\u6709\u592a\u5927\u7684\u95ee\u9898\u3002<\/p>\n<p><strong>\u53ea\u66f4\u65b0\u7f13\u5b58\uff0c\u7531\u7f13\u5b58\u81ea\u5df1\u540c\u6b65\u66f4\u65b0\u6570\u636e\u5e93\uff08Read\/Write Through Pattern\uff09<\/strong><br \/>\u8fd9\u79cd\u65b9\u6cd5\u76f8\u5f53\u4e8e\u662f\u4e1a\u52a1\u53ea\u66f4\u65b0\u7f13\u5b58\uff0c\u518d\u7531\u7f13\u5b58\u53bb\u540c\u6b65\u66f4\u65b0\u6570\u636e\u5e93\u3002 \u4e00\u4e2a Write Through \u7684 \u4f8b\u5b50\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042363257\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5176\u53ef\u80fd\u6267\u884c\u7684\u6d41\u7a0b\u987a\u5e8f\u4e3a\uff1a<br \/>\u5ba2\u6237\u7aef 1 \u89e6\u53d1\u66f4\u65b0\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 2 \u89e6\u53d1\u67e5\u8be2\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 1 \u66f4\u65b0\u7f13\u5b58\u4e2d\u6570\u636e A\uff0c\u7f13\u5b58\u540c\u6b65\u66f4\u65b0\u6570\u636e\u5e93\u4e2d\u6570\u636e A\uff0c\u518d\u8fd4\u56de\u7ed3\u679c<br \/>\u5ba2\u6237\u7aef 2 \u67e5\u8be2\u7f13\u5b58\u4e2d\u6570\u636e A\uff0c\u547d\u4e2d\u8fd4\u56de<\/p>\n<p>Read Through \u548c WriteThrough \u7684\u6d41\u7a0b\u7c7b\u4f3c\uff0c\u53ea\u662f\u5728\u5ba2\u6237\u7aef\u67e5\u8be2\u6570\u636e A \u65f6\uff0c\u5982\u679c\u7f13\u5b58\u4e2d\u6570\u636e A \u5931\u6548\u4e86\uff08\u8fc7\u671f\u6216\u88ab\u9a71\u9010\u6dd8\u6c70\uff09\uff0c\u5219\u7f13\u5b58\u4f1a\u540c\u6b65\u53bb\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u6570\u636e A\uff0c\u5e76\u7f13\u5b58\u8d77\u6765\uff0c\u518d\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef<\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u7f13\u5b58\u4e0d\u4e00\u81f4\u7684\u6982\u7387\u6781\u4f4e\uff0c\u53ea\u4e0d\u8fc7\u9700\u8981\u5bf9\u7f13\u5b58\u8fdb\u884c\u4e13\u95e8\u7684\u6539\u9020\u3002<\/p>\n<p><strong>\u53ea\u66f4\u65b0\u7f13\u5b58\uff0c\u7531\u7f13\u5b58\u81ea\u5df1\u5f02\u6b65\u66f4\u65b0\u6570\u636e\u5e93\uff08Write Behind Cache Pattern\uff09<\/strong><br \/>\u8fd9\u79cd\u65b9\u5f0f\u6027\u8be6\u5355\u4e8e\u662f\u4e1a\u52a1\u53ea\u64cd\u4f5c\u66f4\u65b0\u7f13\u5b58\uff0c\u518d\u7531\u7f13\u5b58\u5f02\u6b65\u53bb\u66f4\u65b0\u6570\u636e\u5e93\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042363258\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5176\u53ef\u80fd\u7684\u6267\u884c\u6d41\u7a0b\u987a\u5e8f\u4e3a\uff1a<br \/>\u5ba2\u6237\u7aef 1 \u89e6\u53d1\u66f4\u65b0\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 2 \u89e6\u53d1\u67e5\u8be2\u6570\u636e A \u7684\u903b\u8f91<br \/>\u5ba2\u6237\u7aef 1 \u66f4\u65b0\u7f13\u5b58\u4e2d\u7684\u6570\u636e A\uff0c\u8fd4\u56de<br \/>\u5ba2\u6237\u7aef 2 \u67e5\u8be2\u7f13\u5b58\u4e2d\u7684\u6570\u636e A\uff0c\u547d\u4e2d\u8fd4\u56de<br \/>\u7f13\u5b58\u5f02\u6b65\u66f4\u65b0\u6570\u636e A \u5230\u6570\u636e\u5e93\u4e2d<\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u7684\u4f18\u52bf\u662f\u8bfb\u5199\u7684\u6027\u80fd\u90fd\u975e\u5e38\u597d\uff0c\u57fa\u672c\u4e0a\u53ea\u8981\u64cd\u4f5c\u5b8c\u5185\u5b58\u540e\u5c31\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u4e86\uff0c\u4f46\u662f\u5176\u662f\u975e\u5f3a\u4e00\u81f4\u6027\uff0c\u5b58\u5728\u4e22\u5931\u6570\u636e\u7684\u60c5\u51b5\u3002\u5982\u679c\u5728\u7f13\u5b58\u5f02\u6b65\u5c06\u6570\u636e\u66f4\u65b0\u5230\u6570\u636e\u5e93\u4e2d\u65f6\uff0c\u7f13\u5b58\u670d\u52a1\u6302\u4e86\uff0c\u6b64\u65f6\u672a\u66f4\u65b0\u5230\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u5c31\u4e22\u5931\u4e86\u3002<\/p>\n<p><strong>\u603b\u7ed3<\/strong><br \/>\u4e0a\u9762\u8bb2\u5230\u7684\u51e0\u79cd\u7f13\u5b58\u66f4\u65b0\u7684\u8bbe\u8ba1\u65b9\u5f0f\uff0c\u90fd\u662f\u524d\u4eba\u603b\u7ed3\u51fa\u6765\u7684\u7ecf\u9a8c\uff0c\u8fd9\u4e9b\u65b9\u5f0f\u6216\u591a\u6216\u5c11\u90fd\u6709\u4e00\u4e9b\u5f0a\u7aef\uff0c\u5e76\u4e0d\u5b8c\u7f8e\uff0c\u5b9e\u9645\u4e0a\u4e5f\u5f88\u96be\u6709\u5b8c\u7f8e\u7684\u8bbe\u8ba1\u3002 \u5927\u5bb6\u5728\u505a\u7cfb\u7edf\u8bbe\u8ba1\u7684\u65f6\u5019\uff0c\u4e5f\u4e0d\u8981\u53bb\u8ffd\u6c42\u5b8c\u7f8e\uff0c\u8981\u6709\u4e00\u4e9b\u53d6\u820d\uff0c\u627e\u5230\u4e00\u79cd\u6700\u9002\u5408\u81ea\u5df1\u4e1a\u52a1\u573a\u666f\u7684\u65b9\u5f0f\u5c31\u884c<\/p>\n<p>\u4f5c\u8005\uff1a\u8ffd\u5149\u8005<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042363253\">https:\/\/segmentfault.com\/a\/1190000042363253<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u9610\u660e\u4e00\u4e0b Mysql \u548c Redis \u7684\u5173\u7cfb\uff1aMysql \u662f\u6570\u636e\u5e93\uff0c\u7528\u6765\u6301\u4e45\u5316\u6570\u636e\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4fdd\u8bc1\u6570\u636e\u7684\u53ef\u9760 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006290","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006290"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006290\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}