Generic

PEXPIREAT

Sets a timeout on key. After the timeout has expired, the key will automatically be deleted.

Arguments

keybodystrrequired

The key to expire.

unix_time_millisecondsbodyint | datetime.datetimerequired

The timeout in unix milliseconds 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 unix timestampredis.set("mykey", "Hello")redis.pexpireat("mykey", int(time.time() * 1000) )# With a datetime objectredis.set("mykey", "Hello")redis.pexpireat("mykey", datetime.datetime.now() + datetime.timedelta(seconds=5))
Loading search…