Interface RedisStringCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection, DefaultedRedisConnection, RedisClusterConnection, RedisCommands, RedisConnection, RedisConnectionUtils.RedisConnectionProxy, StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection, DefaultStringRedisConnection, JedisClusterConnection, JedisConnection, LettuceClusterConnection, LettuceConnection
String/Value-specific commands supported by Redis.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch, Marcin Grzejszczak
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic enumSETcommand arguments forNX,XX. -
Method Summary
Modifier and TypeMethodDescriptionAppend avaluetokey.Count the number of set bits (population counting) in value stored atkey.Count the number of set bits (population counting) of value stored atkeybetweenstartandend.bitField(byte @NonNull [] key, @NonNull BitFieldSubCommands subCommands) Get / Manipulate specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset stored at a givenkey.bitOp(@NonNull RedisStringCommands.BitOperation op, byte @NonNull [] destination, byte @NonNull [] @NonNull ... keys) Perform bitwise operations between strings.default LongReturn the position of the first bit set to givenbitin a string.Return the position of the first bit set to givenbitin a string.Decrement an integer value stored as string value ofkeyby 1.Decrement an integer value stored as string value ofkeybyvalue.byte[]Get the value ofkey.Get the bit value atoffsetof value atkey.byte[]Return the value atkeyand delete the key.byte[]getEx(byte @NonNull [] key, @NonNull Expiration expiration) Return the value atkeyand expire the key by applyingExpiration.byte[]Get a substring of value ofkeybetweenstartandend.byte[]Setvalueofkeyand return its old value.Increment an integer value stored as string value ofkeyby 1.Increment a floating point number value ofkeybyvalue.Increment an integer value stored ofkeybyvalue.List<byte[]> 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.Set thevalueand expiration inmillisecondsforkey.Setvalueforkey.set(byte @NonNull [] key, byte @NonNull [] value, @NonNull Expiration expiration, @NonNull RedisStringCommands.SetOption option) Setvalueforkeyapplying timeouts fromexpirationif set and inserting/updating values depending onoption.Sets the bit atoffsetin value stored atkey.Set thevalueand expiration insecondsforkey.byte[]setGet(byte @NonNull [] key, byte @NonNull [] value, @NonNull Expiration expiration, @NonNull RedisStringCommands.SetOption option) Setvalueforkey.Setvalueforkey, only ifkeydoes not exist.voidOverwrite parts ofkeystarting at the specifiedoffsetwith givenvalue.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
-
mGet
-
set
-
set
Boolean set(byte @NonNull [] key, byte @NonNull [] value, @NonNull Expiration expiration, @NonNull 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
byte[] setGet(byte @NonNull [] key, byte @NonNull [] value, @NonNull Expiration expiration, @NonNull 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
-
setEx
-
pSetEx
-
mSet
-
mSetNX
-
incr
-
incrBy
-
incrBy
-
decr
-
decrBy
-
append
-
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
-
getBit
-
setBit
-
bitCount
-
bitCount
-
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
Long bitOp(@NonNull RedisStringCommands.BitOperation op, byte @NonNull [] destination, byte @NonNull [] @NonNull ... keys) 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
-