class RedisScriptLoader {

    Mono<StoredScript> storedScript() {
        return Mono.defer(() -> {
            Flux<String> source = this.storedScript.get();
            return source.next().map(sha -> new StoredScript(sha, source));
        });
    }

}

class RedisScriptLoaderTest {

    @RegisterExtension
    static RedisStandaloneConnectionSetupExtension extension;

    @Test
    @DisplayName("should cache loaded sha")
    void shouldCache() {

        RedisScriptLoader scriptLoader = new RedisScriptLoader(extension.getScriptingReactiveCommands(), "hello-world.lua");

        assertThat(scriptLoader.storedScript().block(Duration.ofSeconds(5)).getSha()).isNotEmpty();

        scriptFlush();

        assertThat(scriptLoader.storedScript().block(Duration.ofSeconds(5)).getSha()).isNotEmpty();
    }

}