@Override public Mono<Boolean> add(K key, V value, double score) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.zAdd(rawKey(key), score, rawValue(value)).map(l -> l != 0)); }
/** * Add a {@literal tuples} to a sorted set at {@literal key}, or update their score if it already exists. * * @param key must not be {@literal null}. * @param tuples must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a> */ default Mono<Long> zAdd(ByteBuffer key, Collection<? extends Tuple> tuples) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(tuples, "Tuples must not be null!"); return zAdd(Mono.just(ZAddCommand.tuples(tuples).to(key))).next().map(resp -> resp.getOutput().longValue()); }
/** * Add {@literal value} to a sorted set at {@literal key}, or update its {@literal score} if it already exists. * * @param key must not be {@literal null}. * @param score must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a> */ default Mono<Long> zAdd(ByteBuffer key, Double score, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(score, "Score must not be null!"); Assert.notNull(value, "Value must not be null!"); return zAdd(Mono.just(ZAddCommand.tuple(new DefaultTuple(ByteUtils.getBytes(value), score)).to(key))).next() .map(resp -> resp.getOutput().longValue()); }
@Override public Mono<Long> addAll(K key, Collection<? extends TypedTuple<V>> tuples) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(tuples, "Key must not be null!"); return createMono(connection -> Flux.fromIterable(tuples) // .map(t -> new DefaultTuple(ByteUtils.getBytes(rawValue(t.getValue())), t.getScore())) // .collectList() // .flatMap(serialized -> connection.zAdd(rawKey(key), serialized))); }
@Override public Mono<Boolean> add(K key, V value, double score) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.zAdd(rawKey(key), score, rawValue(value)).map(l -> l != 0)); }
/** * Add a {@literal tuples} to a sorted set at {@literal key}, or update their score if it already exists. * * @param key must not be {@literal null}. * @param tuples must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a> */ default Mono<Long> zAdd(ByteBuffer key, Collection<? extends Tuple> tuples) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(tuples, "Tuples must not be null!"); return zAdd(Mono.just(ZAddCommand.tuples(tuples).to(key))).next().map(resp -> resp.getOutput().longValue()); }
@Override public Mono<Boolean> add(K key, V value, double score) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.zAdd(rawKey(key), score, rawValue(value)).map(l -> l != 0)); }
/** * Add a {@literal tuples} to a sorted set at {@literal key}, or update their score if it already exists. * * @param key must not be {@literal null}. * @param tuples must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a> */ default Mono<Long> zAdd(ByteBuffer key, Collection<? extends Tuple> tuples) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(tuples, "Tuples must not be null!"); return zAdd(Mono.just(ZAddCommand.tuples(tuples).to(key))).next().map(resp -> resp.getOutput().longValue()); }
/** * Add {@literal value} to a sorted set at {@literal key}, or update its {@literal score} if it already exists. * * @param key must not be {@literal null}. * @param score must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a> */ default Mono<Long> zAdd(ByteBuffer key, Double score, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(score, "Score must not be null!"); Assert.notNull(value, "Value must not be null!"); return zAdd(Mono.just(ZAddCommand.tuple(new DefaultTuple(ByteUtils.getBytes(value), score)).to(key))).next() .map(resp -> resp.getOutput().longValue()); }
/** * Add {@literal value} to a sorted set at {@literal key}, or update its {@literal score} if it already exists. * * @param key must not be {@literal null}. * @param score must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a> */ default Mono<Long> zAdd(ByteBuffer key, Double score, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(score, "Score must not be null!"); Assert.notNull(value, "Value must not be null!"); return zAdd(Mono.just(ZAddCommand.tuple(new DefaultTuple(ByteUtils.getBytes(value), score)).to(key))).next() .map(resp -> resp.getOutput().longValue()); }
@Override public Mono<Long> addAll(K key, Collection<? extends TypedTuple<V>> tuples) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(tuples, "Key must not be null!"); return createMono(connection -> Flux.fromIterable(tuples) // .map(t -> new DefaultTuple(ByteUtils.getBytes(rawValue(t.getValue())), t.getScore())) // .collectList() // .flatMap(serialized -> connection.zAdd(rawKey(key), serialized))); }
@Override public Mono<Long> addAll(K key, Collection<? extends TypedTuple<V>> tuples) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(tuples, "Key must not be null!"); return createMono(connection -> Flux.fromIterable(tuples) // .map(t -> new DefaultTuple(ByteUtils.getBytes(rawValue(t.getValue())), t.getScore())) // .collectList() // .flatMap(serialized -> connection.zAdd(rawKey(key), serialized))); }