Appends a value to a key.
Appends a value to a key.
the key to be appended
the value to append
the length of the string after the append operation
2.0.0
if the value stored at key is not of type string
Counts the number of bits set to 1 in a string.
Counts the number of bits set to 1 in a string.
the key for which the bitcount should be returned
the number of bits set to 1
2.6.0
if the value stored at key is not of type string
Non-existent keys are treated as empty strings, so the command will return zero.
Counts the number of bits set to 1 in a string from start offset to end offset.
Counts the number of bits set to 1 in a string from start offset to end offset.
the key for which the bitcount should be returned
start offset in bytes
end offset in bytes
the number of bits set to 1 in the specified interval
2.6.0
if the value stored at key is not of type string
Non-existent keys are treated as empty strings, so the command will return zero.
Performs bitwise AND operation between two strings.
Performs bitwise AND operation between two strings.
left operand
right operand
key where the result of the operation will be stored
the size of the string stored in the destination key, that is equal to the size of the longest input string
2.6.0
if the value stored at key is not of type string
When an operation is performed between strings having different lengths, all the strings shorter than the longest string in the set are treated as if they were zero-padded up to the length of the longest string. The same holds true for non-existent keys, that are considered as a stream of zero bytes up to the length of the longest string.
Performs bitwise NOT operation on a given string.
Performs bitwise NOT operation on a given string.
the source key
key where the result of the operation will be stored
the size of the string stored in the destination key, that is equal to the size of the longest input string
2.6.0
if the value stored at key is not of type string
Performs bitwise OR operation between two strings.
Performs bitwise OR operation between two strings.
left operand
right operand
key where the result of the operation will be stored
the size of the string stored in the destination key, that is equal to the size of the longest input string
2.6.0
if the value stored at key is not of type string
When an operation is performed between strings having different lengths, all the strings shorter than the longest string in the set are treated as if they were zero-padded up to the length of the longest string. The same holds true for non-existent keys, that are considered as a stream of zero bytes up to the length of the longest string.
Performs bitwise XOR operation between two strings.
Performs bitwise XOR operation between two strings.
left operand
right operand
key where the result of the operation will be stored
the size of the string stored in the destination key, that is equal to the size of the longest input string
2.6.0
if the value stored at key is not of type string
When an operation is performed between strings having different lengths, all the strings shorter than the longest string in the set are treated as if they were zero-padded up to the length of the longest string. The same holds true for non-existent keys, that are considered as a stream of zero bytes up to the length of the longest string.
Decrements the integer value of a key by one.
Decrements the integer value of a key by one.
the key to decrement
the value of key after the decrement
1.0.0
if the key contains a value of the wrong type or contains a string that cannot be represented as integer
If the key does not exist, it is set to 0 before performing the operation.
Decrements the integer value of a key by the given amount.
Decrements the integer value of a key by the given amount.
the key to decrement
the decrement
the value of key after the decrement
1.0.0
if the key contains a value of the wrong type or contains a string that cannot be represented as integer
If the key does not exist, it is set to 0 before performing the operation.
Returns the value stored at key.
Returns the value stored at key.
the target key
value stored at key, or None
if the key does not exist
1.0.0
if the value stored at key is not of type string
Returns the bit value at offset in the string value stored at key.
Returns the bit value at offset in the string value stored at key.
the target key
the position in the string
true if the bit is set to 1, false otherwise
2.2.0
if the value stored at key is not of type string
Returns a substring of the string stored at a key.
Returns a substring of the string stored at a key.
the target key
the start offset (inclusive)
the end offset (inclusive)
the substring determined by the specified offsets
2.4.0
if the value stored at key is not of type string
Both offsets are inclusive, i.e. [start, end]. The function handles out of range requests by limiting the resulting range to the actual length of the string.
Sets the string value of a key and return its old value.
Sets the string value of a key and return its old value.
the target key
the value to set key to
the old value, or None
if the latter did not exist
1.0.0
if the value stored at key is not of type string
Increments the integer value of a key by one.
Increments the integer value of a key by one.
the key to increment
the value of key after the increment
1.0.0
if the key contains a value of the wrong type or contains a string that cannot be represented as integer
If the key does not exist, it is set to 0 before performing the operation.
Increments the integer value of a key by the given amount.
Increments the integer value of a key by the given amount.
the key to increment
the increment
the value of key after the decrement
1.0.0
if the key contains a value of the wrong type or contains a string that cannot be represented as integer
If the key does not exist, it is set to 0 before performing the operation.
Increment the float value of a key by the given amount.
Increment the float value of a key by the given amount.
the key to increment
the increment
the value of key after the decrement
2.6.0
if the key contains a value of the wrong type, the current key content or the specified increment are not parseable as a double precision floating point number
If the key does not exist, it is set to 0 before performing the operation.
Returns the values of all specified keys.
Returns the values of all specified keys.
the target key
additional keys
list of value(s) stored at the specified key(s)
1.0.0
For every key that does not hold a string value or does not exist, None
is returned.
Because of this, the operation never fails.
Returns a Map
containing the specified key(s) paired to their respective value(s).
Returns a Map
containing the specified key(s) paired to their respective value(s).
the target key
additional keys
map of key-value pairs
1.0.0
Every key that does not hold a string value or does not exist will be removed from the
resulting Map
.
Atomically sets multiple keys to multiple values.
Atomically sets multiple keys to multiple values.
key-value pair to be set
additional key-value pairs to be set
1.0.1
MSET replaces existing values with new values, just as regular SET.
Atomically sets multiple keys to multiple values.
Atomically sets multiple keys to multiple values.
key-value pairs to be set
1.0.1
if the provided keyValueMap is empty
MSET replaces existing values with new values, just as regular SET.
Atomically sets multiple keys to multiple values, only if none of the keys exist.
Atomically sets multiple keys to multiple values, only if none of the keys exist.
key-value pair to be set
additional key-value pairs to be set
1.0.1
MSETNX will not perform any operation at all even if just a single key already exists.
Atomically sets multiple keys to multiple values, only if none of the keys exist.
Atomically sets multiple keys to multiple values, only if none of the keys exist.
key-value pairs to be set
1.0.1
if the provided keyValueMap is empty
MSETNX will not perform any operation at all even if just a single key already exists.
Sets the value and expiration in milliseconds of a key.
Sets the value and expiration in milliseconds of a key.
target key to set
value to be stored at key
time-to-live in milliseconds
2.6.0
If key already holds a value, it is overwritten, regardless of its type.
Sets the string value of a key.
Sets the string value of a key.
target key to set
value to be stored at key
1.0.0
If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.
Sets or clears the bit at offset in the string value stored at key.
Sets or clears the bit at offset in the string value stored at key.
key for which the bit should be set
position where the bit should be set
true sets the bit to 1, false sets it to 0
2.2.0
if the key contains a value of the wrong type
When key does not exist, a new string value is created. The string is grown to make sure it can hold a bit at offset. When the string at key is grown, added bits are set to 0.
Sets the value and expiration in seconds of a key.
Sets the value and expiration in seconds of a key.
target key to set
value to be stored at key
time-to-live in seconds
2.0.0
If key already holds a value, it is overwritten, regardless of its type.
Sets the value and expiration of a key.
Sets the value and expiration of a key.
target key to set
value to be stored at key
time-to-live, up to milliseconds precision
2.6.0
If key already holds a value, it is overwritten, regardless of its type.
Sets the value of a key, only if the key does not exist.
Sets the value of a key, only if the key does not exist.
target key to set
value to be stored at key
true if the key was set, false otherwise
1.0.0
Overwrites part of a string at key starting at the specified offset.
Overwrites part of a string at key starting at the specified offset.
target key
position from which the string must be overwritten
string value to be set at given offset
the length of the string after it was modified by the command
2.2.0
if the key contains a value of the wrong type
If the offset is larger than the current length of the string at key, the string is padded with zero-bytes to make offset fit. Non-existing keys are considered as empty strings, so this command will make sure it holds a string large enough to be able to set value at offset.
Sets the string value of a key, optionally using a condition and/or expiring it.
Sets the string value of a key, optionally using a condition and/or expiring it.
target key to set
value to be stored at key
when defined, sets an expiration time on the value
when defined, only set the value if the condition is verified
true
if the value was set, false
if the operation was not performed because the
provided condition was not met
2.6.12
If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.
Returns the length of the string value stored in a key.
Returns the length of the string value stored in a key.
target key
the length of the string stored at key, or 0 when the key does not exist
2.2.0
if the key contains a value of the wrong type
Returns a substring of the string stored at a key.
Returns a substring of the string stored at a key.
the target key
the start offset (inclusive)
the end offset (inclusive)
the substring determined by the specified offsets
(Since version 2.0.1) SUBSTR has been renamed to GETRANGE in Redis versions > 2.0.0
1.0.0
if the value stored at key is not of type string
Both offsets are inclusive, i.e. [start, end]. The function handles out of range requests by limiting the resulting range to the actual length of the string.
This trait implements strings commands.