assert redis.set("key", "value") == True

assert redis.get("key") == "value"

Arguments

key
str
required
The key
value
TValue
required
The value, if this is not a string, we will use JSON.stringify to convert it to a string.
get
bool
Instead of returning True, this will cause the command to return the old value stored at key, or None when key did not exist.
ex
int
Sets an expiration (in seconds) to the key.
px
int
Sets an expiration (in milliseconds) to the key.
exat
int
Set the UNIX timestamp in seconds until the key expires.
pxat
int
Set the UNIX timestamp in milliseconds until the key expires.
keepttl
bool
Keeps the old expiration if the key already exists.
nx
bool
Only set the key if it does not already exist.
xx
bool
Only set the key if it already exists.

Response

True if the key was set. If get is specified, this will return the old value stored at key, or None when the key did not exist.
assert redis.set("key", "value") == True

assert redis.get("key") == "value"