跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 反应式 redis 流程问题
未分類
23 2 月 2022

反应式 redis 流程问题

反应式 redis 流程问题

資深大佬 : 77yf77yf77yf 18

return valueOperations.set(regCodeKey, regCode, Duration.of(10, TimeUnit.MINUTES.toChronoUnit()))
.then(reactiveRedisTemplate.hasKey(regCodeObtainRecordKey)
.doOnSuccess(r ->
listOperations.leftPush(regCodeObtainRecordKey, current).doOnSuccess(x -> {
if (!r) {
reactiveRedisTemplate.expire(regCodeObtainRecordKey, Duration.of(30, TimeUnit.DAYS.toChronoUnit())).subscribe();
}
}).subscribe()
))
.doOnSuccess(r -> EmailMessageType.REGISTER.send(Lists.newArrayList(email), Lists.newArrayList(regCode)))
.map(r -> {
if (r) {
return GsonUtil.getGson().toJson(ResponseVO.ResponseCodeMsgMapping.SENDREG_SUCC.getResponse());
} else {
return GsonUtil.getGson().toJson(ResponseVO.ResponseCodeMsgMapping.SYS_ERROR.getResponse());
}
});
11 行的 doOnSuccess 能否在第二行 then 中的操作完全做完才进行(我感觉应该不太行)
如果不行应该怎么改
大佬有話說 (5)

  • 資深大佬 : yidinghe

    建议代码粘贴到 github ,然后在这里贴链接

  • 主 資深大佬 : 77yf77yf77yf

    return valueOperations.set(regCodeKey, regCode, Duration.of(10, TimeUnit.MINUTES.toChronoUnit()))
    .then(reactiveRedisTemplate.hasKey(regCodeObtainRecordKey)
    .doOnSuccess(hasRecordKey ->
    listOperations.leftPush(regCodeObtainRecordKey, current).doOnSuccess(x -> {
    if (!hasRecordKey) {
    reactiveRedisTemplate.expire(regCodeObtainRecordKey, Duration.of(30, TimeUnit.DAYS.toChronoUnit()))
    .doOnSuccess(opeSucc -> {
    if (opeSucc) {
    EmailMessageType.REGISTER.send(Lists.newArrayList(email), Lists.newArrayList(regCode));
    }
    }).subscribe();
    }
    }).subscribe()
    ))
    .map(r -> {
    if (r) {
    return ResponseVO.ResponseCodeMsgMapping.SENDREG_SUCC.getResponse().toJson();
    } else {
    return ResponseVO.ResponseCodeMsgMapping.SYS_ERROR.getResponse().toJson();
    }
    });
    想了想改了之后是这样的
    但是还是有个问题,最后我要将整个流程完成与否的结果转化为 Mono<String>,但是如果像这样在最后 map 的话应该只是对 hasKey 的结果进行转化,有没有什么办法以最后整个流程完成的结果来转化

  • 主 資深大佬 : 77yf77yf77yf

    @77yf77yf77yf github.com/inusang/img/blob/main/1.png

  • 主 資深大佬 : 77yf77yf77yf

    @yidinghe 已贴到 github ,有空希望再看一下,谢谢

  • 資深大佬 : jalena

    ` “`java `这样贴不好吗?

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具