2
反应式 redis 流程问题
source link: https://www.v2ex.com/t/818394
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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 中的操作完全做完才进行(我感觉应该不太行)
如果不行应该怎么改
.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 中的操作完全做完才进行(我感觉应该不太行)
如果不行应该怎么改
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK