{"id":159102,"date":"2020-09-23T11:14:17","date_gmt":"2020-09-23T03:14:17","guid":{"rendered":"http:\/\/4563.org\/?p=159102"},"modified":"2020-09-23T11:14:17","modified_gmt":"2020-09-23T03:14:17","slug":"%e5%be%88%e5%a4%9a%e4%b8%9a%e5%8a%a1%e7%94%a8-redis-%e5%81%9a%e4%ba%86%e7%bc%93%e5%ad%98%ef%bc%8c%e5%81%87%e5%a6%82%e5%ae%a2%e6%88%b7%e7%ab%af%e5%91%bd%e4%b8%ad%e7%9a%84%e7%bc%93%e5%ad%98%ef%bc%8c","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=159102","title":{"rendered":"\u5f88\u591a\u4e1a\u52a1\u7528 Redis \u505a\u4e86\u7f13\u5b58\uff0c\u5047\u5982\u5ba2\u6237\u7aef\u547d\u4e2d\u7684\u7f13\u5b58\uff0c\u90a3\u8fd8\u9700\u8981\u5148\u4ece Redis \u4e2d\u8bfb\u53d6\u7684\u6570\u636e\u53cd\u5e8f\u5217\u5316\u6210\u5bf9\u8c61\u518d\u5e8f\u5217\u5316\u6210 JSON \u7ed9\u524d\u7aef\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5f88\u591a\u4e1a\u52a1\u7528 Redis \u505a\u4e86\u7f13\u5b58\uff0c\u5047\u5982\u5ba2\u6237\u7aef\u547d\u4e2d\u7684\u7f13\u5b58\uff0c\u90a3\u8fd8\u9700\u8981\u5148\u4ece Redis \u4e2d\u8bfb\u53d6\u7684\u6570\u636e\u53cd\u5e8f\u5217\u5316\u6210\u5bf9\u8c61\u518d\u5e8f\u5217\u5316\u6210 JSON \u7ed9\u524d\u7aef\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qwerthhusn <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6bd4\u5982\uff0c\u7528\u7684 Spring Web RestController<\/p>\n<pre><code>@GetMapping(\"\/data\") public Data get() {   byte[] dataBS = redis.get(\"key\");   if (dataBS == null) {     return getFromDB();   } else {     \/\/ \u53ef\u80fd\u7528\u4e86 Kryo \u6216\u8005 FST \u6216\u8005 Protobuf \u7b49\u5e8f\u5217\u5316\u534f\u8bae     Data data = deserialize(dataBS, Data.class);     return data;   } } <\/code><\/pre>\n<p>\u603b\u611f\u89c9\u53ef\u4ee5\u76f4\u63a5\u5b58 JSON\uff0c\u7136\u540e\u4ece Redis \u4e2d\u76f4\u63a5\u53d6\u51fa byte[]\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u7701\u6389\u4e00\u6b21\u53cd\u5e8f\u5217\u5316\u548c\u5e8f\u5217\u5316\u7684\u6d41\u7a0b\u3002\u4f46\u662f\u8fd9\u6837\u5199\u7684\u611f\u89c9\u53ef\u8bfb\u6027\u4e0d\u5f3a\uff0c\u800c\u4e14\u5199\u6cd5\u4e5f\u6bd4\u8f83\u9ebb\u70e6\u3002<\/p>\n<p>\u8bf7\u95ee\u5927\u4f6c\u4eec\uff0c\u4e00\u822c\u9047\u5230\u8fd9\u79cd\u60c5\u5f62\uff0c\u4f60\u4eec\u90fd\u662f\u548b\u505a\u7684\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3421748\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : canbingzt <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 @Cacheable                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3421749\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : qwerthhusn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Cacheable \u53ea\u662f\u7b80\u5316\u4e86\u83b7\u53d6\u903b\u8f91\uff0c\u4f46\u662f\u8fd8\u662f\u9700\u8981\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u548c\u4e8c\u6b21\u5e8f\u5217\u5316\u7684<br \/>@canbingzt                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3421750\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joesonw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd get \u4e00\u4e0b\u7684\u8bf7\u6c42, encode\/decode \u7684 cpu \u6d88\u8017\u5f88\u5c0f\u7684. \u800c\u4e14\u4e07\u4e00\u8bf7\u6c42\u540e\u9762\u8fd8\u6709 filter, \u4f8b\u5982\u6570\u636e\u5b57\u6bb5\u8131\u654f\u5462?                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3421751\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : doufum <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1. spring \u7684 redisTemplate\uff0c\u914d\u7f6e\u7684\u65f6\u5019\u52a0\u4e0a value \u5e8f\u5217\u5316\u65b9\u5f0f\uff0c\u53d6\u7684\u65f6\u5019\u8f6c\u578b\u4e00\u4e0b\u5c31\u884c\u4e86\u5565<br \/>2. \u81ea\u5df1\u5199 Redis \u5de5\u5177\u7c7b\u7684\u5316\uff0c\u91cd\u8f7d\u4e00\u4e0b get \u65b9\u6cd5\uff0c\u5bf9 value \u7684\u5e8f\u5217\u5316 \/\u53cd\u5e8f\u5217\u5316\u52a0\u5165\u5230\u91cd\u8f7d\u7684\u65b9\u6cd5\u91cc\u9762\uff0c\u5165\u53c2 class \u6cdb\u578b\uff0c\u8fd4\u56de\u76f4\u63a5\u63a5\u53d7<br \/>3. \u63a5\u53e3\u52a0\u6ce8\u89e3\uff0c\u7edf\u4e00 AOP \u5904\u7406\uff0c\u5728 AOP \u7684\u65b9\u6cd5\u91cc\u9762\u5904\u7406\u8f6c\u578b\u3001\u5e8f\u5217\u5316\u3001\u53cd\u5e8f\u5217\u5316\uff08\u914d\u5408 1\uff0c2 \uff09                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3421752\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : qwerthhusn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @joesonw \u662f\u7684\uff0c\u7a81\u7136\u8fd9\u4e48\u4e00\u60f3\u4e5f\u5bf9\uff0c\u76f8\u5bf9\u4e8e\u8017\u65f6\u7684 IO \u64cd\u4f5c\uff0c\u6267\u884c\u4e00\u4e9b CPU \u548c\u5185\u5b58\u4efb\u52a1\u5f88\u5feb\uff0c\u8fd9\u70b9\u70b9\u4f18\u5316\u57fa\u672c\u4e0a\u6ca1\u592a\u591a\u610f\u4e49\u3002\u7cfb\u7edf\u7684\u74f6\u9888\u4e5f\u4e0d\u4f1a\u51fa\u73b0\u5728\u8fd9\u91cc\u3002\u3002\u3002\u3002\u3002\u3002\u8fd9\u4e48\u7406\u89e3\u6ca1\u9519\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3421753\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yejianmail <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u91cc\u53ef\u4ee5\u76f4\u63a5\u7528 String \u7684 redisTemplate                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u591a\u4e1a\u52a1\u7528 Redis \u505a\u4e86\u7f13\u5b58\uff0c&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\/159102"}],"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=159102"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/159102\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=159102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=159102"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=159102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}