Extension modules to Redis' native data types and commands
git clone https://github.com/RedisLabsModules/RedisX.git
cd RedisX
cargo build --release
redis-server --loadmodule ./target/release/libredisx.so
Time complexity: O(1)
Atomically sets key to value and returns the old value stored at key and set key to timeout after a given number of seconds. Returns an error when key exists but does not hold a string value.
This command is equivalent to executing the following commands:
GETSET mykey value
EXPIRE mykey seconds
Bulk string reply: the value of key, or nil when key does not exist.
Time complexity: O(1)
Get the value of key and set key to timeout after a given number of seconds. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GETEX only handles string values.
This command is equivalent to executing the following commands:
GET mykey
EXPIRE mykey seconds
Bulk string reply: the value of key, or nil when key does not exist.
Time complexity: O(1)
Removes the specified keys and returns the old value stored at key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GETDEL only handles string values.
This command is equivalent to executing the following commands:
GET mykey
DEL mykey
Bulk string reply: the value of key, or nil when key does not exist.
Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size
If key already exists and is a string, this command prepend the value at the begin of the string. If key does not exist it is created and set as an empty string, so PREPEND will be similar to SET in this special case.
redis> EXISTS mykey
(integer) 0
redis> X.PREPEND mykey "World"
(integer) 5
redis> X.PREPEND mykey "Hello "
(integer) 11
redis> GET mykey
"Hello World"
redis>
Integer reply: the length of the string after the prepend operation.