Redis EXPIREAT key timestamp
Redis EXPIREAT Command
The Redis EXPIREAT command is used to convert relative timeouts to absolute timeouts for the AOF persistence mode. It can be used directly to specify that a given key should expire at a given time in the future.
EXPIREAT has the same effect and semantic as EXPIRE, but instead of specifying the number of seconds representing the TTL (time to live), it takes an absolute Unix timestamp (seconds since January 1, 1970).
Here are some common uses and scenarios for the "EXPIREAT" command:
- Scheduled Expirations: Set a specific date and time for a key to expire.
- Synchronization: Coordinate key expirations across multiple systems with a fixed timestamp.
- Time-bound Data: Manage data that is valid until a specific point in time.
- Automated Cleanup: Schedule the automatic deletion of keys at a precise future moment.
Syntax:
Expireat KEY_NAME TIME_IN_UNIX_TIMESTAMP
Available since
1.2.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 Type
Integer
Example: Redis EXPIREAT
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> EXISTS key (integer) 1 127.0.0.1:6379> EXPIREAT key 1039840000 (integer) 1 127.0.0.1:6379> EXISTS key (integer) 0
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://www.w3resource.com/redis/redis-expireat-key-timestamp.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics