Reactor系列(十四)buffer缓冲

java#reactor#flux#buffer

缓冲

视频讲解: https://www.bilibili.com/vide...
Reactor系列(十四)buffer缓冲_第1张图片
FluxMonoTestCase.java

package com.example.reactor;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;

import java.util.List;

@Slf4j
public class FluxMonoTestCase extends BaseTestCase {
    @Test
    public void buffer(){
        Flux stringFlux = Flux.just("a","b","c","d","e","f","g");
        stringFlux.subscribe(x -> System.out.print("->"+x));
        System.out.println();
        Flux> listFlux = stringFlux.buffer(2);
        listFlux.subscribe(x -> System.out.print("->"+x));
    }
}

结果:

\->a->b->c->d->e->f->g \->\[a, b\]->\[c, d\]->\[e, f\]->\[g\]

关注公众号,坚持每天3分钟视频学习
Reactor系列(十四)buffer缓冲_第2张图片

你可能感兴趣的:(java,reactor,flux,buffer,缓存)