redisquarkus-reactive

Reactive redis add key-value-expiration


I'm using quarkus, it has a reactive connection to redis. I need to add key-value-expiration. Due to the fact that this is reactive programming, I do not understand how to do this, please help.

there is an example, but it doesn't have an example of adding a key with a value: https://quarkus.io/guides/redis#creating-the-increment-service

ReactiveKeyCommands does not have an add, set, setex methods.


Solution

  • private final ReactiveValueCommands<String, String> valueCommands;
    
    public ConstructorMyBean(ReactiveRedisDataSource reactive) {
            this.valueCommands = reactive.value(String.class, String.class);
    }
    
    valueCommands.setex("key", 90000, "value")
       .subscribeAsCompletionStage().thenApply(status-> "Successfully");
    

    how stupid I am, but to be honest, before I asked, nothing worked