# With a unix timestamp
redis.set("mykey", "Hello")
redis.pexpireat("mykey", int(time.time() * 1000) )

# With a datetime object
redis.set("mykey", "Hello")
redis.pexpireat("mykey", datetime.datetime.now() + datetime.timedelta(seconds=5))

Arguments

key
str
required
The key to expire.
unix_time_milliseconds
int | datetime.datetime
required
The timeout in unix milliseconds timestamp as int or a datetime.datetime object.
nx
bool
Set expiry only when the key has no expiry
xx
bool
Set expiry only when the key has an existing expiry
gt
bool
Set expiry only when the new expiry is greater than current one
lt
bool
Set expiry only when the new expiry is less than current one

Response

True if the timeout was set
# With a unix timestamp
redis.set("mykey", "Hello")
redis.pexpireat("mykey", int(time.time() * 1000) )

# With a datetime object
redis.set("mykey", "Hello")
redis.pexpireat("mykey", datetime.datetime.now() + datetime.timedelta(seconds=5))