Generic
EXPIREAT
Sets a timeout on key. The key will automatically be deleted.
Arguments
keybodystrrequired
The key to set the timeout on.
unix_time_secondsbodyint | datetime.datetimerequired
The timeout in unix seconds timestamp as int or a datetime.datetime object.
nxbodybool
Set expiry only when the key has no expiry
xxbodybool
Set expiry only when the key has an existing expiry
gtbodybool
Set expiry only when the new expiry is greater than current one
ltbodybool
Set expiry only when the new expiry is less than current one
Response
bool
True if the timeout was set
Example
# With a datetime objectredis.set("mykey", "Hello")redis.expireat("mykey", datetime.datetime.now() + datetime.timedelta(seconds=5))# With a unix timestampredis.set("mykey", "Hello")redis.expireat("mykey", int(time.time()) + 5)