w3resource

Redis Keys: PEXPIREAT

Redis PEXPIREAT Command

Redis Pexpireat command is used to set the expiry of key in unix timestamp at which the key will expire is specified in milliseconds instead of seconds. After the expiry time, key will not be available in redis.

Here are some common uses and scenarios for the "PEXPIREAT" command:

  • Scheduled Expirations: Schedule keys to expire at a specific future time with millisecond precision.
  • Temporal Data Management: Manage temporary data or session information with precise expiry times.
  • Token Expiration: Implement time-bound tokens or authentication mechanisms.
  • Automated Cleanup: Ensure automatic deletion of keys at predefined future times.

Syntax:

PEXPIREAT KEY_NAME TIME_IN_MILLISECONDS_IN_UNIX_TIMESTAMP

Available since

2.6.0.

Return Value

    Integer reply, specifically:
  • 1, if the timeout is set for the key.
  • 0, if the key does not exist or timeout could not set.

Return Value

Integer

Example: Redis PEXPIREAT

First, create a key in redis and set some value in it.

127.0.0.1:6379> SET key "Apple"
OK
127.0.0.1:6379> PEXPIREAT key 1555555555005
(integer) 1
127.0.0.1:6379> TTL key
(integer) 113072338
127.0.0.1:6379> PTTL key
(integer) 113072329357

Previous: PEXPIRE
Next: PTTL



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/redis/redis-pexpireat-keymilliseconds-timestamp.php