{"id":139470,"date":"2020-07-15T04:52:09","date_gmt":"2020-07-14T20:52:09","guid":{"rendered":"http:\/\/4563.org\/?p=139470"},"modified":"2020-07-15T04:52:09","modified_gmt":"2020-07-14T20:52:09","slug":"%e4%b8%8d%e8%80%83%e8%99%91%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%9a%84%e8%af%9d%ef%bc%8c%e7%bc%93%e5%ad%98%e6%98%af%e4%b8%8d%e6%98%af%e5%ba%94%e8%af%a5%e8%bf%99%e6%a0%b7%e5%86%99","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=139470","title":{"rendered":"\u4e0d\u8003\u8651\u591a\u7ebf\u7a0b\u7684\u8bdd\uff0c\u7f13\u5b58\u662f\u4e0d\u662f\u5e94\u8be5\u8fd9\u6837\u5199"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4e0d\u8003\u8651\u591a\u7ebf\u7a0b\u7684\u8bdd\uff0c\u7f13\u5b58\u662f\u4e0d\u662f\u5e94\u8be5\u8fd9\u6837\u5199               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : luxinfl <\/span>  <span><i><\/i> 11<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u66f4\u65b0\u64cd\u4f5c\uff1a\u5148\u66f4\u65b0 A \u4fe1\u606f\uff0c\u7136\u540e\u518d\u4ece\u5e93\u91cc\u67e5\u8be2 A \u6240\u6709\u5b57\u6bb5\uff0c\u7136\u540e\u653e\u5165 redis \u7f13\u5b58\uff1f\uff1f\u6709\u6ca1\u6709\u66f4\u597d\u7684\u505a\u6cd5\uff1f<\/p>\n<pre><code>public void updateMerchantInfo(TbUserInfo tbUserInfo) {          \/\/\u66f4\u65b0\u5546\u6237\u4fe1\u606f         tbUserInfoMapper.updateByPrimaryKeySelective(tbUserInfo);          \/\/\u7f13\u5b58\u66f4\u65b0\u540e\u7684\u6570\u636e         TbUserInfo merchantInfo = tbUserInfoMapper.getOneByCondition(tbUserInfo);         String redisKey = ZbpsConstant.RedisConstants.STORE_INFO + merchantInfo.getPlatformCode() + merchantInfo.getPlatformUserCode();         if(merchantInfo != null){             RedisUtils.set(redisKey,GsonUtils.objectToJson(merchantInfo),24*3600);         } } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>19<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2637036\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wangltfwow <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u6837\u4e5f\u53ef\u4ee5\u5176\u5b9e\uff0c\u4f46\u7f13\u5b58\u7684\u64cd\u4f5c\u90fd\u7edf\u4e00\u653e\u5230\u6ce8\u89e3\u4e0a\u4f1a\u4f18\u96c5\u70b9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637037\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : luxinfl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wangltfwow \u7528 spring \u81ea\u5e26\u7684\u6ce8\u89e3\u5417\uff1f\u6211\u770b\u4e86\u90a3\u51e0\u4e2a\u5e38\u7528\u7684\uff0c\u6ca1\u6709\u90a3\u79cd\u66f4\u65b0\u540e\u81ea\u52a8\u52a0\u8f7d\u7684\u5427\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637038\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @luxinfl CachePut \u4e86\u89e3\u4e00\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637039\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : luxinfl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dallaslu CachePut \u653e\u5728 update \u65b9\u6cd5\u4e0a\u9762\u5417\uff1f\u8fd9\u4e2a\u4e5f\u53ea\u80fd\u7f13\u5b58\u5165\u53c2\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637040\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : myCupOfTea <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4eec\u662f\u81ea\u5df1\u5199\u7684\u6ce8\u89e3 \u4e5f\u4e0d\u96be,,                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637041\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yidinghe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7f13\u5b58 API \u7684\u4e24\u79cd\u5c01\u88c5\u65b9\u5f0f\uff1a<\/p>\n<p>1. \u6ce8\u89e3\u5c01\u88c5\uff0c\u81ea\u5df1\u5b9e\u73b0\u96be\u5ea6\u5f88\u9ad8\uff0c\u4e00\u822c\u76f4\u63a5\u4f7f\u7528 Spring \u7684 @Cacheable \u6ce8\u89e3 https:\/\/www.baeldung.com\/spring-cache-tutorial<\/p>\n<p>2. LoadingCache \u65b9\u5f0f\uff0c\u5c06 if-else \u5224\u65ad\u5c01\u88c5\u4e3a\u53c2\u6570\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<p>TbUserInfoCache cache = new TbUserInfoCache();<br \/>TbUserInfo info = cache.get(key, (_key) -&gt; tbUserInfoMapper.query(_key));<\/p>\n<p>\u8fd9\u4e2a get() \u65b9\u6cd5\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u5982\u679c\u7f13\u5b58\u4e2d\u5b58\u5728\u5219\u76f4\u63a5\u6839\u636e key \u8fd4\u56de\u7f13\u5b58\u5185\u5bb9\uff0c\u5426\u5219\u8c03\u7528\u7b2c\u4e8c\u4e2a\u53c2\u6570\u67e5\u8be2\u6570\u636e\uff0c\u653e\u5165\u7f13\u5b58\u518d\u8fd4\u56de\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637042\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4eec\u662f\u4f7f\u7528 canal \u7edf\u4e00\u7ba1\u7406\u7f13\u5b58\u7684\u6e05\u9664\uff0c\u5728\u8c03\u7528\u65b9\u6cd5\u524d\u5224\u65ad\u662f\u5426\u5b58\u5728\u7f13\u5b58\uff0c\u6ca1\u6709\u5c31\u83b7\u53d6 MySQL \u7684\u6570\u636e\uff0c\u7136\u540e\u7f13\u5b58\u8d77\u6765\u3002\u5728\u65b9\u6cd5\u91cc\u9762\u5904\u7406\u7f13\u5b58\u76f8\u5173\u7684\u903b\u8f91\uff0c\u4e2a\u4eba\u89c9\u5f97\u4e0d\u592a\u597d\uff0c\u5c31\u50cf AOP \u4e00\u6837\uff0c\u4e0d\u8981\u6c61\u67d3\u4e1a\u52a1\u903b\u8f91\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637043\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : luxinfl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @myCupOfTea \u662f\u4e0d\u96be\uff0c\u8fd9\u4e0d\u8fc7\u8fd9\u6837\u4e0d\u5c01\u88c5\u5199\u8d77\u6765\u786e\u5b9e\u633a\u96be\u770b\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637044\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : RedBeanIce <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Spring \u7684 @Cacheable \u4e2a\u4eba\u662f\u4e0d\u4f7f\u7528\u7684\u3002<\/p>\n<p>\u9664\u975e\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u6ca1\u6709\u90a3\u4e2a\u4e60\u60ef\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637045\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : daimubai <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e5f\u662f\u4e0d\u7528 Spring \u6ce8\u89e3\u7684\u3002<br \/>\u5220\u9664\u7f13\u5b58 -&gt; \u66f4\u65b0\u6570\u636e\u5e93 -&gt; \u5237\u65b0\u5230\u7f13\u5b58\uff0c\u8fd9\u79cd\u89e3\u51b3\u65b9\u6cd5\u9002\u5408\u5e76\u53d1\u91cf\u4e0d\u9ad8\u7684\u60c5\u51b5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637046\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yiyi11 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u66f4\u65b0\u64cd\u4f5c\u53ea\u5220\u9664\u7f13\u5b58\uff0c\u66f4\u65b0\u7f13\u5b58\u7531\u8bfb\u64cd\u4f5c\u5b8c\u6210\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637047\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @luxinfl \u7528 CachePut \u7684\u8bdd\uff0c\u53ef\u4ee5\u5728\u65b9\u6cd5\u91cc return \u8981\u8fd4\u56de\u7684\u503c\uff0c\u7136\u540e\u628a result \u5199\u5165\u7f13\u5b58\u3002\u6216\u8005\u5728 update \u65b9\u6cd5\u4e0a\u7528 CacheEvict \u6ce8\u89e3\uff0c\u53e6\u6709\u67e5\u8be2\u65b9\u6cd5\u7528 Cacheable \u6ce8\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637048\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 312ybj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             redis \u8ddf Spring \u6709\u96c6\u6210\uff0c \u4f7f\u7528\u6ce8\u89e3\u5c31\u884c\uff0c\u4e0a\u7684\u65b9\u6cd5\u5c31\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637049\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wysnylc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Sping Cache \u6709 jdkpoxy \u7684 this \u95ee\u9898\u548c\u5355 key \u65e0\u6cd5\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\u95ee\u9898,\u5176\u4ed6\u7684\u5f88\u4e0d\u9519                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637050\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : DixCouleur <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6b6a\u4e2a\uff0c\u95ee\u4e00\u4e0b\uff0cTbUserInfo \u8fd9\u4e2a\u53d8\u91cf\u540d\u7684 Tb \u524d\u7f00\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u5728\u597d\u591a\u5730\u65b9\u770b\u89c1\u8fc7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637051\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iweisi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @DixCouleur table \u7684\u7f29\u5199                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637052\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : luxinfl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @yiyi11 \u90a3\u8bfb\u64cd\u4f5c\u6bcf\u6b21\u90fd\u8981\u53bb\u67e5\u6570\u636e\u5e93\uff1f\u8fd9\u4e0d\u5408\u7406\u5427\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637053\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MeowOvO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @luxinfl \u8bfb\u64cd\u4f5c\u8bfb\u5230\u7f13\u5b58\u5c31\u4e0d\u67e5\u6570\u636e\u5e93\u4e86- &#8211;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2637054\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yiyi11 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @luxinfl \u4e3a\u4ec0\u4e48\u4f1a\u6bcf\u6b21\u67e5\u6570\u636e\u5e93\uff1f\u7b2c\u4e00\u6b21\u8bfb\u64cd\u4f5c\u4ea7\u751f\u4e86\u7f13\u5b58\uff0c\u540e\u9762\u5c31\u4e00\u76f4\u8bfb\u7f13\u5b58\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u8003\u8651\u591a\u7ebf\u7a0b\u7684\u8bdd\uff0c\u7f13\u5b58\u662f\u4e0d\u662f\u5e94\u8be5\u8fd9&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/139470"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=139470"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/139470\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=139470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=139470"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=139470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}