Call hstrlen on JedisCluster.
We now call hstrlen on the Cluster client instead of using our execute(…) fallback and determining the correct cluster node ourselves. Closes #2392
This commit is contained in:
@@ -237,13 +237,14 @@ public interface RedisHashCommands {
|
||||
Cursor<Map.Entry<byte[], byte[]>> 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 <a href="https://redis.io/commands/hstrlen">Redis Documentation: HSTRLEN</a>
|
||||
*/
|
||||
@Nullable
|
||||
Long hStrLen(byte[] key, byte[] field);
|
||||
|
||||
@@ -19,7 +19,6 @@ import redis.clients.jedis.params.ScanParams;
|
||||
import redis.clients.jedis.resps.ScanResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -289,7 +288,11 @@ class JedisClusterHashCommands implements RedisHashCommands {
|
||||
@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) {
|
||||
|
||||
Reference in New Issue
Block a user