@Nullable @Override public Long hStrLen(byte[] key, byte[] field) { return Long.class.cast(connection.execute("HSTRLEN", key, Collections.singleton(field))); }
@Nullable @Override public Long unlink(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); return connection.<Long> execute("UNLINK", Arrays.asList(keys), Collections.emptyList()).stream() .mapToLong(val -> val).sum(); }
@Nullable @Override public Long touch(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); return connection.<Long> execute("TOUCH", Arrays.asList(keys), Collections.emptyList()).stream() .mapToLong(val -> val).sum(); }
@Nullable @Override public <T> T execute(String command, byte[] key, Collection<byte[]> args) { return execute(command, key, args, it -> (T) it.getOne()); }
@Override public List<Long> bitField(byte[] key, BitFieldSubCommands subCommands) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(subCommands, "Command must not be null!"); byte[][] args = JedisConverters.toBitfieldCommandArguments(subCommands); try { return connection.execute("BITFIELD", key, Arrays.asList(args), Connection::getIntegerMultiBulkReply); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long bitPos(byte[] key, boolean bit, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead."); List<byte[]> args = new ArrayList<>(3); args.add(LettuceConverters.toBit(bit)); if (range.getLowerBound().isBounded()) { args.add(range.getLowerBound().getValue().map(LettuceConverters::toBytes).get()); } if (range.getUpperBound().isBounded()) { args.add(range.getUpperBound().getValue().map(LettuceConverters::toBytes).get()); } return Long.class.cast(connection.execute("BITPOS", key, args)); }
@Override public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(serializedValue, "Serialized value must not be null!"); if (ttlInMillis > Integer.MAX_VALUE) { throw new UnsupportedOperationException("Jedis does not support ttlInMillis exceeding Integer.MAX_VALUE."); } connection.getClusterCommandExecutor().executeCommandOnSingleNode((JedisClusterCommandCallback<String>) client -> { if (!replace) { return client.restore(key, Long.valueOf(ttlInMillis).intValue(), serializedValue); } return JedisConverters.toString(this.connection.execute("RESTORE", key, Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes ("REPLACE")))); }, connection.clusterGetNodeForKey(key)); }
@Nullable @Override public Long hStrLen(byte[] key, byte[] field) { return Long.class.cast(connection.execute("HSTRLEN", key, Collections.singleton(field))); }
@Nullable @Override public Long hStrLen(byte[] key, byte[] field) { return Long.class.cast(connection.execute("HSTRLEN", key, Collections.singleton(field))); }
@Nullable @Override public Long unlink(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); return connection.<Long> execute("UNLINK", Arrays.asList(keys), Collections.emptyList()).stream() .mapToLong(val -> val).sum(); }
@Nullable @Override public Long touch(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); return connection.<Long> execute("TOUCH", Arrays.asList(keys), Collections.emptyList()).stream() .mapToLong(val -> val).sum(); }
@Nullable @Override public Long unlink(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); return connection.<Long> execute("UNLINK", Arrays.asList(keys), Collections.emptyList()).stream() .mapToLong(val -> val).sum(); }
@Nullable @Override public Long touch(byte[]... keys) { Assert.notNull(keys, "Keys must not be null!"); return connection.<Long> execute("TOUCH", Arrays.asList(keys), Collections.emptyList()).stream() .mapToLong(val -> val).sum(); }
@Nullable @Override public <T> T execute(String command, byte[] key, Collection<byte[]> args) { return execute(command, key, args, it -> (T) it.getOne()); }
@Nullable @Override public <T> T execute(String command, byte[] key, Collection<byte[]> args) { return execute(command, key, args, it -> (T) it.getOne()); }
@Override public List<Long> bitField(byte[] key, BitFieldSubCommands subCommands) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(subCommands, "Command must not be null!"); byte[][] args = JedisConverters.toBitfieldCommandArguments(subCommands); try { return connection.execute("BITFIELD", key, Arrays.asList(args), Connection::getIntegerMultiBulkReply); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public List<Long> bitField(byte[] key, BitFieldSubCommands subCommands) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(subCommands, "Command must not be null!"); byte[][] args = JedisConverters.toBitfieldCommandArguments(subCommands); try { return connection.execute("BITFIELD", key, Arrays.asList(args), Connection::getIntegerMultiBulkReply); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long bitPos(byte[] key, boolean bit, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead."); List<byte[]> args = new ArrayList<>(3); args.add(LettuceConverters.toBit(bit)); if (range.getLowerBound().isBounded()) { args.add(range.getLowerBound().getValue().map(LettuceConverters::toBytes).get()); } if (range.getUpperBound().isBounded()) { args.add(range.getUpperBound().getValue().map(LettuceConverters::toBytes).get()); } return Long.class.cast(connection.execute("BITPOS", key, args)); }
@Override public Long bitPos(byte[] key, boolean bit, Range<Long> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead."); List<byte[]> args = new ArrayList<>(3); args.add(LettuceConverters.toBit(bit)); if (range.getLowerBound().isBounded()) { args.add(range.getLowerBound().getValue().map(LettuceConverters::toBytes).get()); } if (range.getUpperBound().isBounded()) { args.add(range.getUpperBound().getValue().map(LettuceConverters::toBytes).get()); } return Long.class.cast(connection.execute("BITPOS", key, args)); }
@Override public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(serializedValue, "Serialized value must not be null!"); if (ttlInMillis > Integer.MAX_VALUE) { throw new UnsupportedOperationException("Jedis does not support ttlInMillis exceeding Integer.MAX_VALUE."); } connection.getClusterCommandExecutor().executeCommandOnSingleNode((JedisClusterCommandCallback<String>) client -> { if (!replace) { return client.restore(key, Long.valueOf(ttlInMillis).intValue(), serializedValue); } return JedisConverters.toString(this.connection.execute("RESTORE", key, Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes ("REPLACE")))); }, connection.clusterGetNodeForKey(key)); }