Interface RedisHashCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection
,DefaultedRedisConnection
,RedisClusterConnection
,RedisCommands
,RedisConnection
,RedisConnectionUtils.RedisConnectionProxy
,StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection
,DefaultStringRedisConnection
,JedisClusterConnection
,JedisConnection
,LettuceClusterConnection
,LettuceConnection
public interface RedisHashCommands
Hash-specific commands supported by Redis.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionhDel
(byte[] key, byte[]... fields) Delete given hashfields
.hExists
(byte[] key, byte[] field) Determine if given hashfield
exists.byte[]
hGet
(byte[] key, byte[] field) Get value for givenfield
from hash atkey
.Map<byte[],
byte[]> hGetAll
(byte[] key) Get entire hash stored atkey
.hIncrBy
(byte[] key, byte[] field, double delta) Incrementvalue
of a hashfield
by the givendelta
.hIncrBy
(byte[] key, byte[] field, long delta) Incrementvalue
of a hashfield
by the givendelta
.Set<byte[]>
hKeys
(byte[] key) Get key set (fields) of hash atkey
.hLen
(byte[] key) Get size of hash atkey
.List<byte[]>
hMGet
(byte[] key, byte[]... fields) Get values for givenfields
from hash atkey
.void
Set multiple hash fields to multiple values using data provided inhashes
byte[]
hRandField
(byte[] key) Return a random field from the hash stored atkey
.List<byte[]>
hRandField
(byte[] key, long count) Return a random field from the hash stored atkey
.Map.Entry<byte[],
byte[]> hRandFieldWithValues
(byte[] key) Return a random field from the hash along with its value stored atkey
.hRandFieldWithValues
(byte[] key, long count) Return a random field from the hash along with its value stored atkey
.hScan
(byte[] key, ScanOptions options) Use aCursor
to iterate over entries in hash atkey
.hSet
(byte[] key, byte[] field, byte[] value) Set thevalue
of a hashfield
.hSetNX
(byte[] key, byte[] field, byte[] value) Set thevalue
of a hashfield
only iffield
does not exist.hStrLen
(byte[] key, byte[] field) Returns the length of the value associated withfield
in the hash stored atkey
.List<byte[]>
hVals
(byte[] key) Get entry set (values) of hash atfield
.
-
Method Details
-
hSet
Set thevalue
of a hashfield
.- Parameters:
key
- must not be null.field
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hSetNX
Set thevalue
of a hashfield
only iffield
does not exist.- Parameters:
key
- must not be null.field
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hGet
Get value for givenfield
from hash atkey
.- Parameters:
key
- must not be null.field
- must not be null.- Returns:
- null when key or field do not exists or when used in pipeline / transaction.
- See Also:
-
hMGet
Get values for givenfields
from hash atkey
. Values are in the order of the requested keys Absent field values are represented usingnull
in the resultingList
.- Parameters:
key
- must not be null.fields
- must not be empty.- Returns:
- empty
List
if key does not exist. null when used in pipeline / transaction. - See Also:
-
hMSet
Set multiple hash fields to multiple values using data provided inhashes
- Parameters:
key
- must not be null.hashes
- must not be null.- See Also:
-
hIncrBy
Incrementvalue
of a hashfield
by the givendelta
.- Parameters:
key
- must not be null.field
- must not be null.delta
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hIncrBy
Incrementvalue
of a hashfield
by the givendelta
.- Parameters:
key
- must not be null.field
- must not be null.delta
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hExists
Determine if given hashfield
exists.- Parameters:
key
- must not be null.field
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hDel
Delete given hashfields
.- Parameters:
key
- must not be null.fields
- must not be empty.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hLen
Get size of hash atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hKeys
Get key set (fields) of hash atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
hVals
Get entry set (values) of hash atfield
.- Parameters:
key
- must not be null.- Returns:
- empty
List
if key does not exist. null when used in pipeline / transaction. - See Also:
-
hGetAll
Get entire hash stored atkey
.- Parameters:
key
- must not be null.- Returns:
- empty
Map
if key does not exist or null when used in pipeline / transaction. - See Also:
-
hRandField
Return a random field from the hash stored atkey
.- Parameters:
key
- must not be null.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
hRandFieldWithValues
Return a random field from the hash along with its value stored atkey
.- Parameters:
key
- must not be null.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
hRandField
Return a random field from the hash stored atkey
. If the providedcount
argument is positive, return a list of distinct fields, capped either atcount
or the hash size. Ifcount
is negative, the behavior changes and the command is allowed to return the same field multiple times. In this case, the number of returned fields is the absolute value of the specified count.- Parameters:
key
- must not be null.count
- number of fields to return.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
hRandFieldWithValues
Return a random field from the hash along with its value stored atkey
. If the providedcount
argument is positive, return a list of distinct fields, capped either atcount
or the hash size. Ifcount
is negative, the behavior changes and the command is allowed to return the same field multiple times. In this case, the number of returned fields is the absolute value of the specified count.- Parameters:
key
- must not be null.count
- number of fields to return.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
hScan
Use aCursor
to iterate over entries in hash atkey
.- Parameters:
key
- must not be null.options
- must not be null.- Returns:
- Since:
- 1.4
- See Also:
-
hStrLen
Returns the length of the value associated withfield
in the hash stored atkey
. If thekey
or thefield
do not exist,0
is returned.- Parameters:
key
- must not be null.field
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.1
- See Also:
-