@Override public <T> Flux<T> execute(ReactiveRedisCallback<T> action) { return execute(action, exposeConnection); }
private <T> Flux<T> createFlux(Function<ReactiveSetCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createFlux(connection -> function.apply(connection.setCommands())); }
private <T> Mono<T> createMono(Function<ReactiveSetCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.setCommands())); }
@Override public Mono<Boolean> rename(K oldKey, K newKey) { Assert.notNull(oldKey, "Old key must not be null!"); Assert.notNull(newKey, "New Key must not be null!"); return createMono(connection -> connection.keyCommands().rename(rawKey(oldKey), rawKey(newKey))); }
@Override public Mono<Boolean> renameIfAbsent(K oldKey, K newKey) { Assert.notNull(oldKey, "Old key must not be null!"); Assert.notNull(newKey, "New Key must not be null!"); return createMono(connection -> connection.keyCommands().renameNX(rawKey(oldKey), rawKey(newKey))); }
@Override public Mono<Boolean> persist(K key) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.keyCommands().persist(rawKey(key))); }
private <T> Flux<T> createFlux(Function<ReactiveZSetCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createFlux(connection -> function.apply(connection.zSetCommands())); }
private <T> Flux<T> createFlux(Function<ReactiveListCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createFlux(connection -> function.apply(connection.listCommands())); }
private <T> Flux<T> createFlux(Function<ReactiveHashCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createFlux(connection -> function.apply(connection.hashCommands())); }
private <T> Flux<T> createFlux(Function<ReactiveGeoCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createFlux(connection -> function.apply(connection.geoCommands())); }
private <T> Mono<T> createMono(Function<ReactiveGeoCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.geoCommands())); }
private <T> Mono<T> createMono(Function<ReactiveHyperLogLogCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.hyperLogLogCommands())); }
private <T> Mono<T> createMono(Function<ReactiveZSetCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.zSetCommands())); }
private <T> Mono<T> createMono(Function<ReactiveHashCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.hashCommands())); }
private <T> Mono<T> createMono(Function<ReactiveStringCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.stringCommands())); }
private <T> Flux<T> createFlux(Function<ReactiveStreamCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createFlux(connection -> function.apply(connection.streamCommands())); }
private <T> Mono<T> createMono(Function<ReactiveStreamCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.streamCommands())); }
private <T> Mono<T> createMono(Function<ReactiveListCommands, Publisher<T>> function) { Assert.notNull(function, "Function must not be null!"); return template.createMono(connection -> function.apply(connection.listCommands())); }
@Override public Mono<Boolean> delete(H key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ private <T> Publisher<T> doInConnection(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signal -> conn.close()); }