getex
GETEX
Get the value and set expire time
GETEX gets the value and can also set or remove expire time.
The options are as follows.
- EX: Set expire time in seconds.
- PX: Set expire time in milliseconds.
- EXAT: Set expire time as timestamp-seconds.
- PXAT: Set expire time as timestamp-milliseconds.
- PERSIST: Remove expire time.
Example
| Command> | getex key ex 10
|
| Result> | value |
| Command> | get key after 10 seconds |
| Result> | (nil)
|
Syntax
GETEX key [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|PERSIST]
- Available since version 6.2.0.
- Time complexity is O(1).