I am trying to get all keys, and then fetch all their values using a ReactiveRedisTemplate in Spring Data Redis
(I know that scan is preferable, but I want to keep it simple for now, unless that is my issue)
code snnipet:
@Service
class Test {
    Logger logger = LoggerFactory.getLogger(Test.class);
    @Autowired
    private ReactiveRedisTemplate<String, String> reactiveRedisTemplate;
    @EventListener(ApplicationReadyEvent.class)
    public void test() {
        logger.info("test");
        var ops = reactiveRedisTemplate.opsForValue();
        var keys = reactiveRedisTemplate.keys("*");
        keys
                .map(l -> {
                    logger.info("test1 " + l);
                    return ops.get(l);
                })
                .doOnNext(
                        l -> logger.info("test2 " + l)
                )
                .blockLast();
        logger.info("done");
    }
}
The problem is that I am getting this output:
test
test1 key1
test2 MonoNext
test1 key2
test2 MonoNext
test1 key3
test2 MonoNext
test1 key4
test2 MonoNext
done
I would expect:
test
test1 key1
test2 val1
test1 key2
test2 val2
test1 key3
test2 val3
test1 key4
test2 val4
done
I am new to rx-java, so I am probably missing something.
 
                        
Found the solution...
I had to use
flatMapinstead of map...full explanation is here