Refine search
/** * Get all the elements in the sorted set at {@literal key} in lexicographical ordering. * * @param key must not be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 1.6 * @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a> */ @Nullable default Set<byte[]> zRangeByLex(byte[] key) { return zRangeByLex(key, Range.unbounded()); }
@Override public Long zCount(byte[] key, Range range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZCOUNT."); byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES); byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES); try { return connection.getCluster().zcount(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range, @Nullable Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYSCOREWITHSCORES must not be null!"); byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES); byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES); if (limit != null) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByScoreWithScores(key, max, min, limit.getOffset(), limit.getCount()), JedisConverters.tupleSetToTupleSet())); } else { pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByScoreWithScores(key, max, min), if (limit != null) { transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScoreWithScores(key, max, min, limit.getOffset(), limit.getCount()), JedisConverters.tupleSetToTupleSet())); } else { transaction(
@Override public Set<byte[]> zRevRangeByScore(byte[] key, Range range, @Nullable Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYSCORE must not be null!"); byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES); byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES); if (limit != null) { pipeline(connection.newJedisResult( connection.getRequiredPipeline().zrevrangeByScore(key, max, min, limit.getOffset(), limit.getCount()))); } else { pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByScore(key, max, min))); if (limit != null) { transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScore(key, max, min, limit.getOffset(), limit.getCount()))); } else { transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScore(key, max, min)));
@Override public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZREVRANGEBYSCOREWITHSCORES."); byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES); byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES); try { if (limit.isUnlimited()) { return JedisConverters.toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min)); } return JedisConverters.toTupleSet( connection.getCluster().zrevrangeByScoreWithScores(key, max, min, limit.getOffset(), limit.getCount())); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Set<byte[]> zRangeByLex(byte[] key, Range range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZRANGEBYLEX."); Assert.notNull(limit, "Limit must not be null!"); byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.toBytes("-")); byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.toBytes("+")); try { if (limit.isUnlimited()) { return connection.getCluster().zrangeByLex(key, min, max); } return connection.getCluster().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount()); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Set<byte[]> zRangeByLex(byte[] key, Range range, @Nullable Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYLEX must not be null!"); byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES); byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES); if (limit != null) { pipeline(connection.newJedisResult( connection.getRequiredPipeline().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount()))); } else { pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeByLex(key, min, max))); if (limit != null) { transaction(connection.newJedisResult( connection.getRequiredTransaction().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount()))); } else { transaction(connection.newJedisResult(connection.getRequiredTransaction().zrangeByLex(key, min, max)));
@Override public Long zCount(byte[] key, Range range) { String min = value(range.getMin().getValue(), range.getMin().isIncluding(), "-inf"); String max = value(range.getMax().getValue(), range.getMax().isIncluding(), "+inf"); return read(key, StringCodec.INSTANCE, RedisCommands.ZCOUNT, key, min, max); }
@Override public Long zRemRangeByScore(byte[] key, Range range) { String min = value(range.getMin().getValue(), range.getMin().isIncluding(), "-inf"); String max = value(range.getMax().getValue(), range.getMax().isIncluding(), "+inf"); return write(key, StringCodec.INSTANCE, ZREMRANGEBYSCORE, key, min, max); }
@Override public Long zCount(byte[] key, Range range) { String min = value(range.getMin().getValue(), range.getMin().isIncluding(), "-inf"); String max = value(range.getMax().getValue(), range.getMax().isIncluding(), "+inf"); return read(key, StringCodec.INSTANCE, RedisCommands.ZCOUNT, key, min, max); }