Redis PEXPIRE
Redis PEXPIRE Command
The Redis Pexpire command is used to set the time of living of a key 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 "PEXPIRE" command:
- Fine-grained TTL: Set precise expiration times for keys in milliseconds.
- Micro-caching: Cache data for very short durations with millisecond precision.
- Rate Limiting: Control access rates with precise time windows.
- Temporary Data: Manage short-lived tokens or temporary state with accuracy.
Syntax:
PEXPIRE KEY_NAME TIME_IN_MILLISECONDS
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 PEXPIRE
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> PEXPIRE key 1800 (integer) 1 127.0.0.1:6379> TTL key (integer) -2 127.0.0.1:6379> PTTL key (integer) -2
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-pexpire-key-milliseconds.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics