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, Marcin Grzejszczak
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic enumSETcommand arguments forNX,XX. -
Method Summary
Modifier and TypeMethodDescriptionappend(byte[] key, byte[] value) Append avaluetokey.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 atkeybetweenstartandend.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 LongbitPos(byte[] key, boolean bit) Return the position of the first bit set to givenbitin a string.Return the position of the first bit set to givenbitin a string.decr(byte[] key) Decrement an integer value stored as string value ofkeyby 1.decrBy(byte[] key, long value) Decrement an integer value stored as string value ofkeybyvalue.byte[]get(byte[] key) Get the value ofkey.getBit(byte[] key, long offset) Get the bit value atoffsetof value atkey.byte[]getDel(byte[] key) Return the value atkeyand delete the key.byte[]getEx(byte[] key, Expiration expiration) Return the value atkeyand expire the key by applyingExpiration.byte[]getRange(byte[] key, long start, long end) Get a substring of value ofkeybetweenstartandend.byte[]getSet(byte[] key, byte[] value) Setvalueofkeyand return its old value.incr(byte[] key) Increment an integer value stored as string value ofkeyby 1.incrBy(byte[] key, double value) Increment a floating point number value ofkeybydelta.incrBy(byte[] key, long value) Increment an integer value stored ofkeybydelta.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 intupleonly if the provided key does not exist.pSetEx(byte[] key, long milliseconds, byte[] value) Set thevalueand expiration inmillisecondsforkey.set(byte[] key, byte[] value) Setvalueforkey.set(byte[] key, byte[] value, Expiration expiration, RedisStringCommands.SetOption option) Setvalueforkeyapplying timeouts fromexpirationif set and inserting/updating values depending onoption.setBit(byte[] key, long offset, boolean value) Sets the bit atoffsetin value stored atkey.setEx(byte[] key, long seconds, byte[] value) Set thevalueand expiration insecondsforkey.byte[]setGet(byte[] key, byte[] value, Expiration expiration, RedisStringCommands.SetOption option) Setvalueforkey.setNX(byte[] key, byte[] value) Setvalueforkey, only ifkeydoes not exist.voidsetRange(byte[] key, byte[] value, long offset) Overwrite parts ofkeystarting at the specifiedoffsetwith 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 atkeyand 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 atkeyand 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
Setvalueofkeyand 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 using null in the resultingList.- Parameters:
keys- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
set
Setvalueforkey.- 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) Setvalueforkeyapplying timeouts fromexpirationif 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:
-
setGet
@Nullable byte[] setGet(byte[] key, byte[] value, Expiration expiration, RedisStringCommands.SetOption option) Setvalueforkey. Return the old string stored at key, or null if key did not exist. An error is returned and SET aborted if the value stored at key is not a string.- 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:
- 3.5
- See Also:
-
setNX
Setvalueforkey, only ifkeydoes not exist.- Parameters:
key- must not be null.value- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
setEx
Set thevalueand expiration insecondsforkey.- Parameters:
key- must not be null.seconds-value- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
pSetEx
Set thevalueand expiration inmillisecondsforkey.- 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 intupleonly 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 ofkeyby 1.- Parameters:
key- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
incrBy
Increment an integer value stored ofkeybydelta.- Parameters:
key- must not be null.value-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
incrBy
Increment a floating point number value ofkeybydelta.- 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 ofkeyby 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 ofkeybyvalue.- Parameters:
key- must not be null.value-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
append
Append avaluetokey.- 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 ofkeybetweenstartandend.- 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 ofkeystarting at the specifiedoffsetwith givenvalue.- Parameters:
key- must not be null.value-offset-- See Also:
-
getBit
Get the bit value atoffsetof value atkey.- Parameters:
key- must not be null.offset-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
setBit
Sets the bit atoffsetin value stored atkey.- Parameters:
key- must not be null.offset-value-- Returns:
- the original bit value stored at
offsetor 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 atkeybetweenstartandend.- 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 givenbitin 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 givenbitin a string.Rangestart 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:
-