跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] reactive 编程+redisson 如何分页的问题

发表于
  • SpringBoot WebFlux 3.1.0 + redisson 3.27.1 + redis stack 7 单机
  • webflux control 要求业务代码返回 mono
    @Bean
    public RouterFunction<ServerResponse> route(CacheHandler cacheHandler) {
        return RouterFunctions.route()
                .GET("......", cacheHandler::xxxxxxx)
                .build();
  • redissonReactiveClient 是 client

    • redissonReactiveClient.getSearch(codec).search(.....); 查询 redis 返回 mono<SearchResult>
    • 所以 cacheHandler::xxxxxxx 中 call 上面的查询
    • 如果做分页的话,SearchResult 里面有 total 和 List<Document>当前页数据
  • 但是我如何在一个请求中查出所有数据呢,也就是 reactive 编程怎么搞个循环查询啊

    • 只能将第一次查询的 mono block()拿到 total 吗,但是貌似 reactive 编程不该是这个写法...
    • 如果 Mono<SearchResult> cc = client.search(..第一页数据).cache();
      • 然后 return cc.flatMap(c -> client.search(.. c.getTotal, 然后传参剩下所有数据)).concatWith(cc).collectList();
      • 测试之后返回空的,因为 client.search 本身也是异步多线程的,这个操作在另一个线程进行,webflux 就给我空数据了,还有就是第二个 search 也拿不到真正的 total

所以这个该咋做啊 -

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.