@Nullable <T> T execute(String command, byte[] key, Collection<byte[]> args, Function<Client, T> responseMapper) { Assert.notNull(command, "Command must not be null!"); Assert.notNull(key, "Key must not be null!"); Assert.notNull(args, "Args must not be null!"); byte[][] commandArgs = getCommandArguments(key, args); RedisClusterNode keyMaster = topologyProvider.getTopology().getKeyServingMasterNode(key); return clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback<T>) client -> JedisClientUtils .execute(command, EMPTY_2D_BYTE_ARRAY, commandArgs, () -> client, responseMapper), keyMaster).getValue(); }
@Override public Long pTtl(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.pttl(key), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return Converters.stringToBoolean(connection.getClusterCommandExecutor() .executeCommandOnSingleNode( (JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue()); }
@Override public byte[] dump(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.dump(key), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public Long pTtl(byte[] key, TimeUnit timeUnit) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode( (JedisClusterCommandCallback<Long>) client -> Converters.millisecondsToTimeUnit(client.pttl(key), timeUnit), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Nullable <T> T execute(String command, byte[] key, Collection<byte[]> args, Function<Client, T> responseMapper) { Assert.notNull(command, "Command must not be null!"); Assert.notNull(key, "Key must not be null!"); Assert.notNull(args, "Args must not be null!"); byte[][] commandArgs = getCommandArguments(key, args); RedisClusterNode keyMaster = topologyProvider.getTopology().getKeyServingMasterNode(key); return clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback<T>) client -> JedisClientUtils .execute(command, EMPTY_2D_BYTE_ARRAY, commandArgs, () -> client, responseMapper), keyMaster).getValue(); }
@Nullable <T> T execute(String command, byte[] key, Collection<byte[]> args, Function<Client, T> responseMapper) { Assert.notNull(command, "Command must not be null!"); Assert.notNull(key, "Key must not be null!"); Assert.notNull(args, "Args must not be null!"); byte[][] commandArgs = getCommandArguments(key, args); RedisClusterNode keyMaster = topologyProvider.getTopology().getKeyServingMasterNode(key); return clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback<T>) client -> JedisClientUtils .execute(command, EMPTY_2D_BYTE_ARRAY, commandArgs, () -> client, responseMapper), keyMaster).getValue(); }
@Override public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return Converters.stringToBoolean(connection.getClusterCommandExecutor() .executeCommandOnSingleNode( (JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue()); }
@Override public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); return Converters.stringToBoolean(connection.getClusterCommandExecutor() .executeCommandOnSingleNode( (JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue()); }
@Override public Long pTtl(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.pttl(key), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public Long pTtl(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.pttl(key), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public byte[] dump(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.dump(key), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public byte[] dump(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.dump(key), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public Long pTtl(byte[] key, TimeUnit timeUnit) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode( (JedisClusterCommandCallback<Long>) client -> Converters.millisecondsToTimeUnit(client.pttl(key), timeUnit), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }
@Override public Long pTtl(byte[] key, TimeUnit timeUnit) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode( (JedisClusterCommandCallback<Long>) client -> Converters.millisecondsToTimeUnit(client.pttl(key), timeUnit), connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key)) .getValue(); }