Interface RedisStringCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection
,DefaultedRedisConnection
,RedisClusterConnection
,RedisCommands
,RedisConnection
,RedisConnectionUtils.RedisConnectionProxy
,StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection
,DefaultStringRedisConnection
,JedisClusterConnection
,JedisConnection
,LettuceClusterConnection
,LettuceConnection
public interface RedisStringCommands
String/Value-specific commands supported by Redis.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
static enum
SET
command arguments forNX
,XX
. -
Method Summary
Modifier and TypeMethodDescriptionappend
(byte[] key, byte[] value) Append avalue
tokey
.bitCount
(byte[] key) Count the number of set bits (population counting) in value stored atkey
.bitCount
(byte[] key, long start, long end) Count the number of set bits (population counting) of value stored atkey
betweenstart
andend
.bitField
(byte[] key, BitFieldSubCommands subCommands) Get / Manipulate specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset stored at a givenkey
.bitOp
(RedisStringCommands.BitOperation op, byte[] destination, byte[]... keys) Perform bitwise operations between strings.default Long
bitPos
(byte[] key, boolean bit) Return the position of the first bit set to givenbit
in a string.Return the position of the first bit set to givenbit
in a string.decr
(byte[] key) Decrement an integer value stored as string value ofkey
by 1.decrBy
(byte[] key, long value) Decrement an integer value stored as string value ofkey
byvalue
.byte[]
get
(byte[] key) Get the value ofkey
.getBit
(byte[] key, long offset) Get the bit value atoffset
of value atkey
.byte[]
getDel
(byte[] key) Return the value atkey
and delete the key.byte[]
getEx
(byte[] key, Expiration expiration) Return the value atkey
and expire the key by applyingExpiration
.byte[]
getRange
(byte[] key, long start, long end) Get a substring of value ofkey
betweenstart
andend
.byte[]
getSet
(byte[] key, byte[] value) Setvalue
ofkey
and return its old value.incr
(byte[] key) Increment an integer value stored as string value ofkey
by 1.incrBy
(byte[] key, double value) Increment a floating point number value ofkey
bydelta
.incrBy
(byte[] key, long value) Increment an integer value stored ofkey
bydelta
.List<byte[]>
mGet
(byte[]... keys) Get multiplekeys
.Set multiple keys to multiple values using key-value pairs provided intuple
.Set multiple keys to multiple values using key-value pairs provided intuple
only if the provided key does not exist.pSetEx
(byte[] key, long milliseconds, byte[] value) Set thevalue
and expiration inmilliseconds
forkey
.set
(byte[] key, byte[] value) Setvalue
forkey
.set
(byte[] key, byte[] value, Expiration expiration, RedisStringCommands.SetOption option) Setvalue
forkey
applying timeouts fromexpiration
if set and inserting/updating values depending onoption
.setBit
(byte[] key, long offset, boolean value) Sets the bit atoffset
in value stored atkey
.setEx
(byte[] key, long seconds, byte[] value) Set thevalue
and expiration inseconds
forkey
.setNX
(byte[] key, byte[] value) Setvalue
forkey
, only ifkey
does not exist.void
setRange
(byte[] key, byte[] value, long offset) Overwrite parts ofkey
starting at the specifiedoffset
with givenvalue
.strLen
(byte[] key) Get the length of the value stored atkey
.
-
Method Details
-
get
Get the value ofkey
.- Parameters:
key
- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- See Also:
-
getDel
Return the value atkey
and delete the key.- Parameters:
key
- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
getEx
Return the value atkey
and expire the key by applyingExpiration
.Use
Expiration.seconds(long)
forEX
.
UseExpiration.milliseconds(long)
forPX
.
UseExpiration.unixTimestamp(long, TimeUnit)
forEXAT | PXAT
.- Parameters:
key
- must not be null.expiration
- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
getSet
Setvalue
ofkey
and return its old value.- Parameters:
key
- must not be null.value
- must not be null.- Returns:
- null if key did not exist before or when used in pipeline / transaction.
- See Also:
-
mGet
Get multiplekeys
. Values are in the order of the requested keys Absent field values are represented usingnull
in the resultingList
.- Parameters:
keys
- must not be null.- Returns:
null
when used in pipeline / transaction.- See Also:
-
set
Setvalue
forkey
.- Parameters:
key
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
set
@Nullable Boolean set(byte[] key, byte[] value, Expiration expiration, RedisStringCommands.SetOption option) Setvalue
forkey
applying timeouts fromexpiration
if set and inserting/updating values depending onoption
.- Parameters:
key
- must not be null.value
- must not be null.expiration
- must not be null. UseExpiration.persistent()
to not set any ttl orExpiration.keepTtl()
to keep the existing expiration.option
- must not be null. UseRedisStringCommands.SetOption.upsert()
to add non existing.- Returns:
- null when used in pipeline / transaction.
- Since:
- 1.7
- See Also:
-
setNX
Setvalue
forkey
, only ifkey
does not exist.- Parameters:
key
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
setEx
Set thevalue
and expiration inseconds
forkey
.- Parameters:
key
- must not be null.seconds
-value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
pSetEx
Set thevalue
and expiration inmilliseconds
forkey
.- Parameters:
key
- must not be null.milliseconds
-value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 1.3
- See Also:
-
mSet
Set multiple keys to multiple values using key-value pairs provided intuple
.- Parameters:
tuple
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
mSetNX
Set multiple keys to multiple values using key-value pairs provided intuple
only if the provided key does not exist.- Parameters:
tuple
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
incr
Increment an integer value stored as string value ofkey
by 1.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
incrBy
Increment an integer value stored ofkey
bydelta
.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
incrBy
Increment a floating point number value ofkey
bydelta
.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
decr
Decrement an integer value stored as string value ofkey
by 1.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
decrBy
Decrement an integer value stored as string value ofkey
byvalue
.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
append
Append avalue
tokey
.- Parameters:
key
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
getRange
Get a substring of value ofkey
betweenstart
andend
.- Parameters:
key
- must not be null.start
-end
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
setRange
void setRange(byte[] key, byte[] value, long offset) Overwrite parts ofkey
starting at the specifiedoffset
with givenvalue
.- Parameters:
key
- must not be null.value
-offset
-- See Also:
-
getBit
Get the bit value atoffset
of value atkey
.- Parameters:
key
- must not be null.offset
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
setBit
Sets the bit atoffset
in value stored atkey
.- Parameters:
key
- must not be null.offset
-value
-- Returns:
- the original bit value stored at
offset
or null when used in pipeline / transaction. - See Also:
-
bitCount
Count the number of set bits (population counting) in value stored atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
bitCount
Count the number of set bits (population counting) of value stored atkey
betweenstart
andend
.- Parameters:
key
- must not be null.start
-end
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
bitField
Get / Manipulate specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset stored at a givenkey
.- Parameters:
key
- must not be null.subCommands
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.1
-
bitOp
Perform bitwise operations between strings.- Parameters:
op
- must not be null.destination
- must not be null.keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
bitPos
Return the position of the first bit set to givenbit
in a string.- Parameters:
key
- the key holding the actual String.bit
- the bit value to look for.- Returns:
- null when used in pipeline / transaction. The position of the first bit set to 1 or 0 according to the request.
- Since:
- 2.1
- See Also:
-
bitPos
Return the position of the first bit set to givenbit
in a string.Range
start and end can contain negative values in order to index bytes starting from the end of the string, where -1 is the last byte, -2 is the penultimate.- Parameters:
key
- the key holding the actual String.bit
- the bit value to look for.range
- must not be null. UseRange.unbounded()
to not limit search.- Returns:
- null when used in pipeline / transaction. The position of the first bit set to 1 or 0 according to the request.
- Since:
- 2.1
- See Also:
-
strLen
Get the length of the value stored atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-