/** * Map a {@link Set} of {@link Tuple} by {@code value} to its {@code score}. * * @param tuples must not be {@literal null}. * @return * @since 2.0 */ public static Map<byte[], Double> toTupleMap(Set<Tuple> tuples) { Assert.notNull(tuples, "Tuple set must not be null!"); Map<byte[], Double> args = new LinkedHashMap<>(tuples.size(), 1); Set<Double> scores = new HashSet<>(tuples.size(), 1); boolean isAtLeastJedis24 = JedisVersionUtil.atLeastJedis24(); for (Tuple tuple : tuples) { if (!isAtLeastJedis24) { if (scores.contains(tuple.getScore())) { throw new UnsupportedOperationException( "Bulk add of multiple elements with the same score is not supported. Add the elements individually."); } scores.add(tuple.getScore()); } args.put(tuple.getValue(), tuple.getScore()); } return args; }
/** * Map a {@link Set} of {@link Tuple} by {@code value} to its {@code score}. * * @param tuples must not be {@literal null}. * @return * @since 2.0 */ public static Map<byte[], Double> toTupleMap(Set<Tuple> tuples) { Assert.notNull(tuples, "Tuple set must not be null!"); Map<byte[], Double> args = new LinkedHashMap<>(tuples.size(), 1); Set<Double> scores = new HashSet<>(tuples.size(), 1); boolean isAtLeastJedis24 = JedisVersionUtil.atLeastJedis24(); for (Tuple tuple : tuples) { if (!isAtLeastJedis24) { if (scores.contains(tuple.getScore())) { throw new UnsupportedOperationException( "Bulk add of multiple elements with the same score is not supported. Add the elements individually."); } scores.add(tuple.getScore()); } args.put(tuple.getValue(), tuple.getScore()); } return args; }
/** * Get elements in {@literal range} from sorted set. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @param limit must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRangeByScore(ByteBuffer key, Range<Double> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.scoresWithin(range).from(key).limitTo(limit))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set in reverse {@literal score} ordering. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @param limit must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRevRangeByScore(ByteBuffer key, Range<Double> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.reverseScoresWithin(range).from(key).limitTo(limit))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set in reverse {@literal score} ordering. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @param limit must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRevRangeByScore(ByteBuffer key, Range<Double> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.reverseScoresWithin(range).from(key).limitTo(limit))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a> */ default Flux<ByteBuffer> zRange(ByteBuffer key, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); return zRange(Mono.just(ZRangeCommand.valuesWithin(range).from(key))) // .flatMap(CommandResponse::getOutput).map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRangeByScore(ByteBuffer key, Range<Double> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.scoresWithin(range).from(key))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @param limit must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRangeByScore(ByteBuffer key, Range<Double> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.scoresWithin(range).from(key).limitTo(limit))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
public StringTuple convert(Tuple source) { return new DefaultStringTuple(source, serializer.deserialize(source.getValue())); } }
/** * Get elements in {@literal range} from sorted set in reverse {@literal score} ordering. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRevRangeByScore(ByteBuffer key, Range<Double> range) { Assert.notNull(key, "Key must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.reverseScoresWithin(range).from(key))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set in reverse {@literal score} ordering. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRevRangeByScore(ByteBuffer key, Range<Double> range) { Assert.notNull(key, "Key must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.reverseScoresWithin(range).from(key))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a> */ default Flux<ByteBuffer> zRangeByScore(ByteBuffer key, Range<Double> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); return zRangeByScore(Mono.just(ZRangeByScoreCommand.scoresWithin(range).from(key))) // .flatMap(CommandResponse::getOutput) // .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
public StringTuple convert(Tuple source) { return new DefaultStringTuple(source, serializer.deserialize(source.getValue())); } }
/** * Get elements in {@literal range} from sorted set in reverse {@literal score} ordering. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a> */ default Flux<ByteBuffer> zRevRange(ByteBuffer key, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); return zRange(Mono.just(ZRangeCommand.reverseValuesWithin(range).from(key))).flatMap(CommandResponse::getOutput) .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set in reverse {@literal score} ordering. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a> */ default Flux<ByteBuffer> zRevRange(ByteBuffer key, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); return zRange(Mono.just(ZRangeCommand.reverseValuesWithin(range).from(key))).flatMap(CommandResponse::getOutput) .map(tuple -> ByteBuffer.wrap(tuple.getValue())); }
/** * Get elements in {@literal range} from sorted set. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return * @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a> */ default Flux<ByteBuffer> zRange(ByteBuffer key, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); return zRange(Mono.just(ZRangeCommand.valuesWithin(range).from(key))) // .flatMap(CommandResponse::getOutput).map(tuple -> ByteBuffer.wrap(tuple.getValue())); }