/** * Execute an arbitrary on the supplied {@link Jedis} instance. * * @param command the command. * @param keys must not be {@literal null}, may be empty. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @return the response, can be be {@literal null}. */ static <T> T execute(String command, byte[][] keys, byte[][] args, Supplier<Jedis> jedis) { return execute(command, keys, args, jedis, it -> (T) it.getOne()); }
/** * Execute an arbitrary on the supplied {@link Jedis} instance. * * @param command the command. * @param keys must not be {@literal null}, may be empty. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @param responseMapper must not be {@literal null}. * @return the response, can be be {@literal null}. * @since 2.1 */ static <T> T execute(String command, byte[][] keys, byte[][] args, Supplier<Jedis> jedis, Function<Client, T> responseMapper) { byte[][] commandArgs = getCommandArguments(keys, args); Client client = sendCommand(command, commandArgs, jedis.get()); return responseMapper.apply(client); }
@Override public boolean isQueueing() { return JedisClientUtils.isInMulti(jedis); }
/** * Send a Redis command and retrieve the {@link Client} for response retrieval. * * @param command the command. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @return the {@link Client} instance used to send the command. */ static Client sendCommand(String command, byte[][] args, Jedis jedis) { Client client = retrieveClient(jedis); sendCommand(client, command, args); return client; }
private static void sendCommand(Client client, String command, byte[][] args) { if (isKnownCommand(command)) { ReflectionUtils.invokeMethod(SEND_COMMAND, client, Command.valueOf(command.trim().toUpperCase()), args); } else { sendProtocolCommand(client, command, args); } }
/** * @param jedis the client instance. * @return {@literal true} if the connection has entered {@literal MULTI} state. */ static boolean isInMulti(Jedis jedis) { return retrieveClient(jedis).isInMulti(); }
<T> T execute(String command, byte[][] args, Function<Client, T> resultMapper, Function<Object, Response<?>> pipelineResponseMapper) { Assert.hasText(command, "A valid command needs to be specified!"); Assert.notNull(args, "Arguments must not be null!"); try { Client client = JedisClientUtils.sendCommand(command, args, this.jedis); if (isQueueing() || isPipelined()) { Response<?> result = pipelineResponseMapper .apply(isPipelined() ? getRequiredPipeline() : getRequiredTransaction()); if (isPipelined()) { pipeline(newJedisResult(result)); } else { transaction(newJedisResult(result)); } return null; } return resultMapper.apply(client); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
private static void sendCommand(Client client, String command, byte[][] args) { if (isKnownCommand(command)) { client.sendCommand(Command.valueOf(command.trim().toUpperCase()), args); } else { client.sendCommand(() -> SafeEncoder.encode(command.trim().toUpperCase()), args); } }
/** * Send a Redis command and retrieve the {@link Client} for response retrieval. * * @param command the command. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @return the {@link Client} instance used to send the command. */ static Client sendCommand(String command, byte[][] args, Jedis jedis) { Client client = retrieveClient(jedis); sendCommand(client, command, args); return client; }
private static void sendCommand(Client client, String command, byte[][] args) { if (isKnownCommand(command)) { ReflectionUtils.invokeMethod(SEND_COMMAND, client, Command.valueOf(command.trim().toUpperCase()), args); } else { sendProtocolCommand(client, command, args); } }
/** * @param jedis the client instance. * @return {@literal true} if the connection has entered {@literal MULTI} state. */ static boolean isInMulti(Jedis jedis) { return retrieveClient(jedis).isInMulti(); }
<T> T execute(String command, byte[][] args, Function<Client, T> resultMapper, Function<Object, Response<?>> pipelineResponseMapper) { Assert.hasText(command, "A valid command needs to be specified!"); Assert.notNull(args, "Arguments must not be null!"); try { Client client = JedisClientUtils.sendCommand(command, args, this.jedis); if (isQueueing() || isPipelined()) { Response<?> result = pipelineResponseMapper .apply(isPipelined() ? getRequiredPipeline() : getRequiredTransaction()); if (isPipelined()) { pipeline(newJedisResult(result)); } else { transaction(newJedisResult(result)); } return null; } return resultMapper.apply(client); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Nullable @Override public Object execute(String command, byte[]... args) { Assert.notNull(command, "Command must not be null!"); Assert.notNull(args, "Args must not be null!"); return clusterCommandExecutor .executeCommandOnArbitraryNode((JedisClusterCommandCallback<Object>) client -> JedisClientUtils.execute(command, EMPTY_2D_BYTE_ARRAY, args, () -> client)) .getValue(); }
/** * Send a Redis command and retrieve the {@link Client} for response retrieval. * * @param command the command. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @return the {@link Client} instance used to send the command. */ static Client sendCommand(String command, byte[][] args, Jedis jedis) { Client client = retrieveClient(jedis); sendCommand(client, command, args); return client; }
/** * Execute an arbitrary on the supplied {@link Jedis} instance. * * @param command the command. * @param keys must not be {@literal null}, may be empty. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @param responseMapper must not be {@literal null}. * @return the response, can be be {@literal null}. * @since 2.1 */ static <T> T execute(String command, byte[][] keys, byte[][] args, Supplier<Jedis> jedis, Function<Client, T> responseMapper) { byte[][] commandArgs = getCommandArguments(keys, args); Client client = sendCommand(command, commandArgs, jedis.get()); return responseMapper.apply(client); }
/** * @param jedis the client instance. * @return {@literal true} if the connection has entered {@literal MULTI} state. */ static boolean isInMulti(Jedis jedis) { return retrieveClient(jedis).isInMulti(); }
@Override public boolean isQueueing() { return JedisClientUtils.isInMulti(jedis); }
<T> T execute(String command, byte[][] args, Function<Client, T> resultMapper, Function<Object, Response<?>> pipelineResponseMapper) { Assert.hasText(command, "A valid command needs to be specified!"); Assert.notNull(args, "Arguments must not be null!"); try { Client client = JedisClientUtils.sendCommand(command, args, this.jedis); if (isQueueing() || isPipelined()) { Response<?> result = pipelineResponseMapper .apply(isPipelined() ? getRequiredPipeline() : getRequiredTransaction()); if (isPipelined()) { pipeline(newJedisResult(result)); } else { transaction(newJedisResult(result)); } return null; } return resultMapper.apply(client); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
return JedisClientUtils.execute(command, new byte[][] { key }, args.toArray(new byte[args.size()][]), () -> client); }, keys).resultsAsList();
/** * Execute an arbitrary on the supplied {@link Jedis} instance. * * @param command the command. * @param keys must not be {@literal null}, may be empty. * @param args must not be {@literal null}, may be empty. * @param jedis must not be {@literal null}. * @param responseMapper must not be {@literal null}. * @return the response, can be be {@literal null}. * @since 2.1 */ static <T> T execute(String command, byte[][] keys, byte[][] args, Supplier<Jedis> jedis, Function<Client, T> responseMapper) { byte[][] commandArgs = getCommandArguments(keys, args); Client client = sendCommand(command, commandArgs, jedis.get()); return responseMapper.apply(client); }