/** * Applies the {@literal key}. Constructs a new command instance with all previously configured properties. * * @param key must not be {@literal null}. * @return a new {@link ZRankCommand} with {@literal key} applied. */ public ZRankCommand storedWithin(ByteBuffer key) { Assert.notNull(key, "Key must not be null!"); return new ZRankCommand(key, value, direction); }
@Override public Flux<NumericResponse<ZRankCommand, Long>> zRank(Publisher<ZRankCommand> commands) { return connection.execute(cmd -> Flux.from(commands).concatMap(command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getValue(), "Value must not be null!"); Mono<Long> result = ObjectUtils.nullSafeEquals(command.getDirection(), Direction.ASC) ? cmd.zrank(command.getKey(), command.getValue()) : cmd.zrevrank(command.getKey(), command.getValue()); return result.map(value -> new NumericResponse<>(command, value)); })); }
/** * Determine the index of element with {@literal value} in a sorted set. * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrank">Redis Documentation: ZRANK</a> */ default Mono<Long> zRank(ByteBuffer key, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return zRank(Mono.just(ZRankCommand.indexOf(value).storedWithin(key))).next().map(NumericResponse::getOutput); }
/** * Determine the index of element with {@literal value} in a sorted set when scored high to low. * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrank">Redis Documentation: ZREVRANK</a> */ default Mono<Long> zRevRank(ByteBuffer key, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return zRank(Mono.just(ZRankCommand.reverseIndexOf(value).storedWithin(key))).next() .map(NumericResponse::getOutput); }
/** * Applies the {@literal key}. Constructs a new command instance with all previously configured properties. * * @param key must not be {@literal null}. * @return a new {@link ZRankCommand} with {@literal key} applied. */ public ZRankCommand storedWithin(ByteBuffer key) { Assert.notNull(key, "Key must not be null!"); return new ZRankCommand(key, value, direction); }
/** * Determine the index of element with {@literal value} in a sorted set. * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrank">Redis Documentation: ZRANK</a> */ default Mono<Long> zRank(ByteBuffer key, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return zRank(Mono.just(ZRankCommand.indexOf(value).storedWithin(key))).next().map(NumericResponse::getOutput); }
/** * Determine the index of element with {@literal value} in a sorted set when scored high to low. * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrank">Redis Documentation: ZREVRANK</a> */ default Mono<Long> zRevRank(ByteBuffer key, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return zRank(Mono.just(ZRankCommand.reverseIndexOf(value).storedWithin(key))).next() .map(NumericResponse::getOutput); }
/** * Determine the index of element with {@literal value} in a sorted set. * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrank">Redis Documentation: ZRANK</a> */ default Mono<Long> zRank(ByteBuffer key, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return zRank(Mono.just(ZRankCommand.indexOf(value).storedWithin(key))).next().map(NumericResponse::getOutput); }
/** * Creates a new {@link ZIncrByCommand} given a {@link ByteBuffer member} to obtain its reversed rank (ordering high * to low). * * @param member must not be {@literal null}. * @return a new {@link ZRankCommand} for {@link Tuple}. */ public static ZRankCommand reverseIndexOf(ByteBuffer member) { Assert.notNull(member, "Member must not be null!"); return new ZRankCommand(null, member, Direction.DESC); }
/** * Creates a new {@link ZIncrByCommand} given a {@link ByteBuffer member} to obtain its reversed rank (ordering high * to low). * * @param member must not be {@literal null}. * @return a new {@link ZRankCommand} for {@link Tuple}. */ public static ZRankCommand reverseIndexOf(ByteBuffer member) { Assert.notNull(member, "Member must not be null!"); return new ZRankCommand(null, member, Direction.DESC); }
@Override public Flux<NumericResponse<ZRankCommand, Long>> zRank(Publisher<ZRankCommand> commands) { return connection.execute(cmd -> Flux.from(commands).concatMap(command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getValue(), "Value must not be null!"); Mono<Long> result = ObjectUtils.nullSafeEquals(command.getDirection(), Direction.ASC) ? cmd.zrank(command.getKey(), command.getValue()) : cmd.zrevrank(command.getKey(), command.getValue()); return result.map(value -> new NumericResponse<>(command, value)); })); }
/** * Applies the {@literal key}. Constructs a new command instance with all previously configured properties. * * @param key must not be {@literal null}. * @return a new {@link ZRankCommand} with {@literal key} applied. */ public ZRankCommand storedWithin(ByteBuffer key) { Assert.notNull(key, "Key must not be null!"); return new ZRankCommand(key, value, direction); }
@Override public Flux<NumericResponse<ZRankCommand, Long>> zRank(Publisher<ZRankCommand> commands) { return connection.execute(cmd -> Flux.from(commands).concatMap(command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getValue(), "Value must not be null!"); Mono<Long> result = ObjectUtils.nullSafeEquals(command.getDirection(), Direction.ASC) ? cmd.zrank(command.getKey(), command.getValue()) : cmd.zrevrank(command.getKey(), command.getValue()); return result.map(value -> new NumericResponse<>(command, value)); })); }
/** * Creates a new {@link ZRankCommand} given a {@link ByteBuffer member} to obtain its rank (ordering low to high). * * @param member must not be {@literal null}. * @return a new {@link ZRankCommand} for {@link Tuple}. */ public static ZRankCommand indexOf(ByteBuffer member) { Assert.notNull(member, "Member must not be null!"); return new ZRankCommand(null, member, Direction.ASC); }
/** * Creates a new {@link ZRankCommand} given a {@link ByteBuffer member} to obtain its rank (ordering low to high). * * @param member must not be {@literal null}. * @return a new {@link ZRankCommand} for {@link Tuple}. */ public static ZRankCommand indexOf(ByteBuffer member) { Assert.notNull(member, "Member must not be null!"); return new ZRankCommand(null, member, Direction.ASC); }
/** * Determine the index of element with {@literal value} in a sorted set when scored high to low. * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrank">Redis Documentation: ZREVRANK</a> */ default Mono<Long> zRevRank(ByteBuffer key, ByteBuffer value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return zRank(Mono.just(ZRankCommand.reverseIndexOf(value).storedWithin(key))).next() .map(NumericResponse::getOutput); }
/** * Creates a new {@link ZIncrByCommand} given a {@link ByteBuffer member} to obtain its reversed rank (ordering high * to low). * * @param member must not be {@literal null}. * @return a new {@link ZRankCommand} for {@link Tuple}. */ public static ZRankCommand reverseIndexOf(ByteBuffer member) { Assert.notNull(member, "Member must not be null!"); return new ZRankCommand(null, member, Direction.DESC); }
/** * Creates a new {@link ZRankCommand} given a {@link ByteBuffer member} to obtain its rank (ordering low to high). * * @param member must not be {@literal null}. * @return a new {@link ZRankCommand} for {@link Tuple}. */ public static ZRankCommand indexOf(ByteBuffer member) { Assert.notNull(member, "Member must not be null!"); return new ZRankCommand(null, member, Direction.ASC); }