{"id":555491,"date":"2022-02-23T21:55:56","date_gmt":"2022-02-23T13:55:56","guid":{"rendered":"http:\/\/4563.org\/?p=555491"},"modified":"2022-02-23T21:55:56","modified_gmt":"2022-02-23T13:55:56","slug":"%e5%8f%8d%e5%ba%94%e5%bc%8f-redis-%e6%b5%81%e7%a8%8b%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=555491","title":{"rendered":"\u53cd\u5e94\u5f0f redis \u6d41\u7a0b\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1> \u53cd\u5e94\u5f0f redis \u6d41\u7a0b\u95ee\u9898 <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 77yf77yf77yf <\/span>  <span><i><\/i> 18<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> return valueOperations.set(regCodeKey, regCode, Duration.of(10, TimeUnit.MINUTES.toChronoUnit()))<br \/> .then(reactiveRedisTemplate.hasKey(regCodeObtainRecordKey)<br \/> .doOnSuccess(r -&gt;<br \/> listOperations.leftPush(regCodeObtainRecordKey, current).doOnSuccess(x -&gt; {<br \/> if (!r) {<br \/> reactiveRedisTemplate.expire(regCodeObtainRecordKey, Duration.of(30, TimeUnit.DAYS.toChronoUnit())).subscribe();<br \/> }<br \/> }).subscribe()<br \/> ))<br \/> .doOnSuccess(r -&gt; EmailMessageType.REGISTER.send(Lists.newArrayList(email), Lists.newArrayList(regCode)))<br \/> .map(r -&gt; {<br \/> if (r) {<br \/> return GsonUtil.getGson().toJson(ResponseVO.ResponseCodeMsgMapping.SENDREG_SUCC.getResponse());<br \/> } else {<br \/> return GsonUtil.getGson().toJson(ResponseVO.ResponseCodeMsgMapping.SYS_ERROR.getResponse());<br \/> }<br \/> });<br \/>11 \u884c\u7684 doOnSuccess \u80fd\u5426\u5728\u7b2c\u4e8c\u884c then \u4e2d\u7684\u64cd\u4f5c\u5b8c\u5168\u505a\u5b8c\u624d\u8fdb\u884c(\u6211\u611f\u89c9\u5e94\u8be5\u4e0d\u592a\u884c)<br \/>\u5982\u679c\u4e0d\u884c\u5e94\u8be5\u600e\u4e48\u6539  <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>) <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"7147784\" 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> \u5efa\u8bae\u4ee3\u7801\u7c98\u8d34\u5230 github \uff0c\u7136\u540e\u5728\u8fd9\u91cc\u8d34\u94fe\u63a5 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7147785\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 77yf77yf77yf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> return valueOperations.set(regCodeKey, regCode, Duration.of(10, TimeUnit.MINUTES.toChronoUnit()))<br \/> .then(reactiveRedisTemplate.hasKey(regCodeObtainRecordKey)<br \/> .doOnSuccess(hasRecordKey -&gt;<br \/> listOperations.leftPush(regCodeObtainRecordKey, current).doOnSuccess(x -&gt; {<br \/> if (!hasRecordKey) {<br \/> reactiveRedisTemplate.expire(regCodeObtainRecordKey, Duration.of(30, TimeUnit.DAYS.toChronoUnit()))<br \/> .doOnSuccess(opeSucc -&gt; {<br \/> if (opeSucc) {<br \/> EmailMessageType.REGISTER.send(Lists.newArrayList(email), Lists.newArrayList(regCode));<br \/> }<br \/> }).subscribe();<br \/> }<br \/> }).subscribe()<br \/> ))<br \/> .map(r -&gt; {<br \/> if (r) {<br \/> return ResponseVO.ResponseCodeMsgMapping.SENDREG_SUCC.getResponse().toJson();<br \/> } else {<br \/> return ResponseVO.ResponseCodeMsgMapping.SYS_ERROR.getResponse().toJson();<br \/> }<br \/> });<br \/>\u60f3\u4e86\u60f3\u6539\u4e86\u4e4b\u540e\u662f\u8fd9\u6837\u7684<br \/>\u4f46\u662f\u8fd8\u662f\u6709\u4e2a\u95ee\u9898\uff0c\u6700\u540e\u6211\u8981\u5c06\u6574\u4e2a\u6d41\u7a0b\u5b8c\u6210\u4e0e\u5426\u7684\u7ed3\u679c\u8f6c\u5316\u4e3a Mono&lt;String&gt;\uff0c\u4f46\u662f\u5982\u679c\u50cf\u8fd9\u6837\u5728\u6700\u540e map \u7684\u8bdd\u5e94\u8be5\u53ea\u662f\u5bf9 hasKey \u7684\u7ed3\u679c\u8fdb\u884c\u8f6c\u5316\uff0c\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u4ee5\u6700\u540e\u6574\u4e2a\u6d41\u7a0b\u5b8c\u6210\u7684\u7ed3\u679c\u6765\u8f6c\u5316 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7147786\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 77yf77yf77yf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> @77yf77yf77yf github.com\/inusang\/img\/blob\/main\/1.png <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7147787\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 77yf77yf77yf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> @yidinghe \u5df2\u8d34\u5230 github \uff0c\u6709\u7a7a\u5e0c\u671b\u518d\u770b\u4e00\u4e0b\uff0c\u8c22\u8c22 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7147788\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jalena <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> ` &#8220;`java `\u8fd9\u6837\u8d34\u4e0d\u597d\u5417\uff1f <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u53cd\u5e94\u5f0f redis \u6d41\u7a0b\u95ee\u9898 \u8cc7\u6df1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/555491"}],"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=555491"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/555491\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=555491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=555491"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=555491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}