英文:
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
英文:
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<String> does not have an add, set, setex methods.
答案1
得分: 0
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-> "成功");
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论