/** * @param source * @return * @since 1.8 */ public static List<String> toStrings(List<byte[]> source) { return BYTES_LIST_TO_STRING_LIST_CONVERTER.convert(source); }
@SuppressWarnings("unchecked") @Nullable private <T> T convertAndReturn(@Nullable Object value, Converter converter) { if (isFutureConversion()) { addResultConverter(converter); return null; } if (!(converter instanceof ListConverter) && value instanceof List) { return (T) new ListConverter<>(converter).convert((List) value); } return value == null ? null : ObjectUtils.nullSafeEquals(converter, identityConverter) ? (T) value : (T) converter.convert(value); }
@Override public List<byte[]> clusterGetKeysInSlot(int slot, Integer count) { RedisClusterNode node = clusterGetNodeForSlot(slot); clusterCommandExecutor .executeCommandOnSingleNode( (JedisClusterCommandCallback<List<byte[]>>) client -> JedisConverters.stringListToByteList() .convert(client.clusterGetKeysInSlot(slot, count != null ? count.intValue() : Integer.MAX_VALUE)), node); return null; }
@Override public List<Point> geoPos(byte[] key, byte[]... members) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(members, "Members must not be null!"); Assert.noNullElements(members, "Members must not contain null!"); try { return JedisConverters.geoCoordinateToPointConverter().convert(connection.getCluster().geopos(key, members)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override protected ScanIteration<byte[]> doScan(long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'SCAN' cannot be called in pipeline / transaction mode."); } ScanParams params = JedisConverters.toScanParams(options); redis.clients.jedis.ScanResult<String> result = connection.getJedis().scan(Long.toString(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getCursor()), JedisConverters.stringListToByteList().convert(result.getResult())); }
@Override protected ScanIteration<Tuple> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'ZSCAN' cannot be called in pipeline / transaction mode."); } ScanParams params = JedisConverters.toScanParams(options); ScanResult<redis.clients.jedis.Tuple> result = connection.getJedis().zscan(key, JedisConverters.toBytes(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getCursor()), JedisConverters.tuplesToTuples().convert(result.getResult())); }
@Override protected ScanIteration<Tuple> doScan(long cursorId, ScanOptions options) { ScanParams params = JedisConverters.toScanParams(options); redis.clients.jedis.ScanResult<redis.clients.jedis.Tuple> result = connection.getCluster().zscan(key, JedisConverters.toBytes(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getCursor()), JedisConverters.tuplesToTuples().convert(result.getResult())); } }.open();
@Override public List<Point> geoPos(byte[] key, byte[]... members) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(members, "Members must not be null!"); Assert.noNullElements(members, "Members must not contain null!"); ListConverter<GeoCoordinate, Point> converter = JedisConverters.geoCoordinateToPointConverter(); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().geopos(key, members), converter)); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().geopos(key, members), converter)); return null; } return converter.convert(connection.getJedis().geopos(key, members)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public List<Point> geoPos(byte[] key, byte[]... members) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(members, "Members must not be null!"); Assert.noNullElements(members, "Members must not contain null!"); ListConverter<GeoCoordinates, Point> converter = LettuceConverters.geoCoordinatesToPointConverter(); try { if (isPipelined()) { pipeline(connection.newLettuceResult(getAsyncConnection().geopos(key, members), converter)); return null; } if (isQueueing()) { transaction(connection.newLettuceResult(getAsyncConnection().geopos(key, members), converter)); return null; } return converter.convert(getConnection().geopos(key, members)); } catch (Exception ex) { throw convertLettuceAccessException(ex); } }
@Override public List<byte[]> hMGet(byte[] key, byte[]... fields) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(fields, "Fields must not be null!"); try { if (isPipelined()) { pipeline(connection.newLettuceResult(getAsyncConnection().hmget(key, fields), LettuceConverters.keyValueListUnwrapper())); return null; } if (isQueueing()) { transaction(connection.newLettuceResult(getAsyncConnection().hmget(key, fields), LettuceConverters.keyValueListUnwrapper())); return null; } return LettuceConverters.<byte[], byte[]> keyValueListUnwrapper().convert(getConnection().hmget(key, fields)); } catch (Exception ex) { throw convertLettuceAccessException(ex); } }
@Override public List<String> geoHash(byte[] key, byte[]... members) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(members, "Members must not be null!"); Assert.noNullElements(members, "Members must not contain null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().geohash(key, members), JedisConverters.bytesListToStringListConverter())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().geohash(key, members), JedisConverters.bytesListToStringListConverter())); return null; } return JedisConverters.bytesListToStringListConverter().convert(connection.getJedis().geohash(key, members)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public List<byte[]> mGet(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); Assert.noNullElements(keys, "Keys must not contain null elements!"); try { if (isPipelined()) { pipeline( connection.newLettuceResult(getAsyncConnection().mget(keys), LettuceConverters.keyValueListUnwrapper())); return null; } if (isQueueing()) { transaction( connection.newLettuceResult(getAsyncConnection().mget(keys), LettuceConverters.keyValueListUnwrapper())); return null; } return LettuceConverters.<byte[], byte[]> keyValueListUnwrapper().convert(getConnection().mget(keys)); } catch (Exception ex) { throw convertLettuceAccessException(ex); } }
/** * @param source * @return * @since 1.8 */ public static List<String> toStrings(List<byte[]> source) { return BYTES_LIST_TO_STRING_LIST_CONVERTER.convert(source); }
@Override public List<byte[]> clusterGetKeysInSlot(int slot, Integer count) { RedisClusterNode node = clusterGetNodeForSlot(slot); clusterCommandExecutor .executeCommandOnSingleNode( (JedisClusterCommandCallback<List<byte[]>>) client -> JedisConverters.stringListToByteList() .convert(client.clusterGetKeysInSlot(slot, count != null ? count.intValue() : Integer.MAX_VALUE)), node); return null; }
@Override public List<Point> geoPos(byte[] key, byte[]... members) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(members, "Members must not be null!"); Assert.noNullElements(members, "Members must not contain null!"); try { return JedisConverters.geoCoordinateToPointConverter().convert(connection.getCluster().geopos(key, members)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override protected ScanIteration<byte[]> doScan(long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'SCAN' cannot be called in pipeline / transaction mode."); } ScanParams params = JedisConverters.toScanParams(options); redis.clients.jedis.ScanResult<String> result = connection.getJedis().scan(Long.toString(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getStringCursor()), JedisConverters.stringListToByteList().convert(result.getResult())); }
@Override protected ScanIteration<Tuple> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'ZSCAN' cannot be called in pipeline / transaction mode."); } ScanParams params = JedisConverters.toScanParams(options); ScanResult<redis.clients.jedis.Tuple> result = connection.getJedis().zscan(key, JedisConverters.toBytes(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getStringCursor()), JedisConverters.tuplesToTuples().convert(result.getResult())); }
@Override protected ScanIteration<Tuple> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'ZSCAN' cannot be called in pipeline / transaction mode."); } ScanParams params = JedisConverters.toScanParams(options); ScanResult<redis.clients.jedis.Tuple> result = connection.getJedis().zscan(key, JedisConverters.toBytes(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getStringCursor()), JedisConverters.tuplesToTuples().convert(result.getResult())); }
@Override protected ScanIteration<Tuple> doScan(long cursorId, ScanOptions options) { ScanParams params = JedisConverters.toScanParams(options); redis.clients.jedis.ScanResult<redis.clients.jedis.Tuple> result = connection.getCluster().zscan(key, JedisConverters.toBytes(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getStringCursor()), JedisConverters.tuplesToTuples().convert(result.getResult())); } }.open();
@Override protected ScanIteration<Tuple> doScan(long cursorId, ScanOptions options) { ScanParams params = JedisConverters.toScanParams(options); redis.clients.jedis.ScanResult<redis.clients.jedis.Tuple> result = connection.getCluster().zscan(key, JedisConverters.toBytes(cursorId), params); return new ScanIteration<>(Long.valueOf(result.getStringCursor()), JedisConverters.tuplesToTuples().convert(result.getResult())); } }.open();