SETEX
Deprecated
As of Redis version 2.6.12, this command is regarded as deprecated.
It can be replaced by SET with the EX argument when migrating or writing new code.
SETEX key seconds value
- Available since:
- Redis Open Source 2.0.0
- Time complexity:
- O(1)
- ACL categories:
-
@write,@string,@slow, - Compatibility:
- Redis Software and Redis Cloud compatibility
Set key to hold the string value and set key to timeout after a given
number of seconds.
This command is equivalent to:
SET key value EX seconds
An error is returned when seconds is invalid.
Required arguments
key
The name of the key.
seconds
The time to live, in seconds.
value
The value to set.
Examples
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard |
✅ Standard |
Return information
Simple string reply:
OK.