diff --git a/src/main/java/redis/clients/jedis/CommandObjects.java b/src/main/java/redis/clients/jedis/CommandObjects.java index 0a24a36900..1a55256e36 100644 --- a/src/main/java/redis/clients/jedis/CommandObjects.java +++ b/src/main/java/redis/clients/jedis/CommandObjects.java @@ -1296,10 +1296,27 @@ public final CommandObject> hsetf(String key, HSetFParams params, Map .add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.LONG_LIST); } - public final CommandObject> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, Map fieldValues) { + public final CommandObject> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, + Map fieldValues) { return new CommandObject<>(addFlatMapArgs(commandArguments(HSETF).key(key).addParams(params).add(getOption) .add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.STRING_LIST); } + + public final CommandObject> hgetf(byte[] key, HGetFParams params, byte[]... fields) { + return new CommandObject<>(commandArguments(HGETF).key(key).addParams(params) + .add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.BINARY_LIST); + } + + public final CommandObject> hsetf(byte[] key, HSetFParams params, Map fieldValues) { + return new CommandObject<>(addFlatMapArgs(commandArguments(HSETF).key(key).addParams(params) + .add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.LONG_LIST); + } + + public final CommandObject> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, + Map fieldValues) { + return new CommandObject<>(addFlatMapArgs(commandArguments(HSETF).key(key).addParams(params).add(getOption) + .add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.BINARY_LIST); + } // Hash commands // Set commands diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index ad846ebdb5..dc35bd3134 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -4734,6 +4734,24 @@ public List hpersist(byte[] key, byte[]... fields) { return connection.executeCommand(commandObjects.hpersist(key, fields)); } + @Override + public List hgetf(byte[] key, HGetFParams params, byte[]... fields) { + checkIsInMultiOrPipeline(); + return connection.executeCommand(commandObjects.hgetf(key, params, fields)); + } + + @Override + public List hsetf(byte[] key, HSetFParams params, Map fieldValues) { + checkIsInMultiOrPipeline(); + return connection.executeCommand(commandObjects.hsetf(key, params, fieldValues)); + } + + @Override + public List hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map fieldValues) { + checkIsInMultiOrPipeline(); + return connection.executeCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues)); + } + @Override public List xread(XReadParams xReadParams, Entry... streams) { checkIsInMultiOrPipeline(); diff --git a/src/main/java/redis/clients/jedis/PipeliningBase.java b/src/main/java/redis/clients/jedis/PipeliningBase.java index 928126a704..724b2cbfd6 100644 --- a/src/main/java/redis/clients/jedis/PipeliningBase.java +++ b/src/main/java/redis/clients/jedis/PipeliningBase.java @@ -790,6 +790,22 @@ public Response> hpersist(String key, String... fields) { return appendCommand(commandObjects.hpersist(key, fields)); } + @Override + public Response> hgetf(String key, HGetFParams params, String... fields) { + return appendCommand(commandObjects.hgetf(key, params, fields)); + } + + @Override + public Response> hsetf(String key, HSetFParams params, Map fieldValues) { + return appendCommand(commandObjects.hsetf(key, params, fieldValues)); + } + + @Override + public Response> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, + Map fieldValues) { + return appendCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues)); + } + @Override public Response sadd(String key, String... members) { return appendCommand(commandObjects.sadd(key, members)); @@ -2136,6 +2152,22 @@ public Response> hpersist(byte[] key, byte[]... fields) { return appendCommand(commandObjects.hpersist(key, fields)); } + @Override + public Response> hgetf(byte[] key, HGetFParams params, byte[]... fields) { + return appendCommand(commandObjects.hgetf(key, params, fields)); + } + + @Override + public Response> hsetf(byte[] key, HSetFParams params, Map fieldValues) { + return appendCommand(commandObjects.hsetf(key, params, fieldValues)); + } + + @Override + public Response> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, + Map fieldValues) { + return appendCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues)); + } + @Override public Response pfadd(byte[] key, byte[]... elements) { return appendCommand(commandObjects.pfadd(key, elements)); diff --git a/src/main/java/redis/clients/jedis/UnifiedJedis.java b/src/main/java/redis/clients/jedis/UnifiedJedis.java index 7a74a7c590..80a5b3f455 100644 --- a/src/main/java/redis/clients/jedis/UnifiedJedis.java +++ b/src/main/java/redis/clients/jedis/UnifiedJedis.java @@ -1745,6 +1745,21 @@ public List hsetf(String key, HSetFParams params, Map fiel public List hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, Map fieldValues) { return executeCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues)); } + + @Override + public List hgetf(byte[] key, HGetFParams params, byte[]... fields) { + return executeCommand(commandObjects.hgetf(key, params, fields)); + } + + @Override + public List hsetf(byte[] key, HSetFParams params, Map fieldValues) { + return executeCommand(commandObjects.hsetf(key, params, fieldValues)); + } + + @Override + public List hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map fieldValues) { + return executeCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues)); + } // Hash commands // Set commands diff --git a/src/main/java/redis/clients/jedis/commands/HashBinaryCommands.java b/src/main/java/redis/clients/jedis/commands/HashBinaryCommands.java index f32eca202e..bd3ced0905 100644 --- a/src/main/java/redis/clients/jedis/commands/HashBinaryCommands.java +++ b/src/main/java/redis/clients/jedis/commands/HashBinaryCommands.java @@ -5,6 +5,9 @@ import java.util.Set; import redis.clients.jedis.args.ExpiryOption; +import redis.clients.jedis.args.HSetFGetOption; +import redis.clients.jedis.params.HGetFParams; +import redis.clients.jedis.params.HSetFParams; import redis.clients.jedis.params.ScanParams; import redis.clients.jedis.resps.ScanResult; @@ -191,4 +194,18 @@ default ScanResult hscanNoValues(byte[] key, byte[] cursor) { * or -1 if the field exists but has no associated expire or -2 if the field does not exist. */ List hpersist(byte[] key, byte[]... fields); + + /** + * For each specified field, returns its value and optionally set the field's remaining expiration + * time in seconds / milliseconds. + * @param key hash + * @param params + * @param fields + * @return values of fields + */ + List hgetf(byte[] key, HGetFParams params, byte[]... fields); + + List hsetf(byte[] key, HSetFParams params, Map fieldValues); + + List hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map fieldValues); } diff --git a/src/main/java/redis/clients/jedis/commands/HashPipelineBinaryCommands.java b/src/main/java/redis/clients/jedis/commands/HashPipelineBinaryCommands.java index e428e72a63..68d785ab98 100644 --- a/src/main/java/redis/clients/jedis/commands/HashPipelineBinaryCommands.java +++ b/src/main/java/redis/clients/jedis/commands/HashPipelineBinaryCommands.java @@ -6,6 +6,9 @@ import redis.clients.jedis.Response; import redis.clients.jedis.args.ExpiryOption; +import redis.clients.jedis.args.HSetFGetOption; +import redis.clients.jedis.params.HGetFParams; +import redis.clients.jedis.params.HSetFParams; import redis.clients.jedis.params.ScanParams; import redis.clients.jedis.resps.ScanResult; @@ -84,4 +87,10 @@ default Response> hscanNoValues(byte[] key, byte[] cursor) { Response> hpttl(byte[] key, byte[]... fields); Response> hpersist(byte[] key, byte[]... fields); + + Response> hgetf(byte[] key, HGetFParams params, byte[]... fields); + + Response> hsetf(byte[] key, HSetFParams params, Map fieldValues); + + Response> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map fieldValues); } diff --git a/src/main/java/redis/clients/jedis/commands/HashPipelineCommands.java b/src/main/java/redis/clients/jedis/commands/HashPipelineCommands.java index 4de4839a9d..588be3b5f1 100644 --- a/src/main/java/redis/clients/jedis/commands/HashPipelineCommands.java +++ b/src/main/java/redis/clients/jedis/commands/HashPipelineCommands.java @@ -6,6 +6,9 @@ import redis.clients.jedis.Response; import redis.clients.jedis.args.ExpiryOption; +import redis.clients.jedis.args.HSetFGetOption; +import redis.clients.jedis.params.HGetFParams; +import redis.clients.jedis.params.HSetFParams; import redis.clients.jedis.params.ScanParams; import redis.clients.jedis.resps.ScanResult; @@ -84,4 +87,10 @@ default Response> hscanNoValues(String key, String cursor) { Response> hpttl(String key, String... fields); Response> hpersist(String key, String... fields); + + Response> hgetf(String key, HGetFParams params, String... fields); + + Response> hsetf(String key, HSetFParams params, Map fieldValues); + + Response> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, Map fieldValues); }