diff --git a/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java index 73b749f421..d2896b75c2 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java @@ -237,13 +237,14 @@ public interface RedisHashCommands { Cursor> hScan(byte[] key, ScanOptions options); /** - * Returns the length of the value associated with {@code field} in the hash stored at {@code key}. If the key or the - * field do not exist, {@code 0} is returned. + * Returns the length of the value associated with {@code field} in the hash stored at {@code key}. If the {@code key} + * or the {@code field} do not exist, {@code 0} is returned. * * @param key must not be {@literal null}. * @param field must not be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 2.1 + * @see Redis Documentation: HSTRLEN */ @Nullable Long hStrLen(byte[] key, byte[] field); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java index 8cf7c22e22..56174d1fa5 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java @@ -18,7 +18,6 @@ import redis.clients.jedis.ScanParams; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -364,7 +363,11 @@ protected ScanIteration> doScan(long cursorId, ScanOptions @Nullable @Override public Long hStrLen(byte[] key, byte[] field) { - return Long.class.cast(connection.execute("HSTRLEN", key, Collections.singleton(field))); + + Assert.notNull(key, "Key must not be null"); + Assert.notNull(field, "Field must not be null"); + + return connection.getCluster().hstrlen(key, field); } private DataAccessException convertJedisAccessException(Exception ex) {