Redis Setex Command

Redis String (string)

The Redis Setex command sets the value and expiration time for the specified key. If the key already exists, the SETEX command will replace the old value.

Syntax

The basic syntax of the Redis Setex command is as follows:

redis 127.0.0.1:6379> SETEX KEY_NAME TIMEOUT VALUE

Available Versions

>= 2.0.0

Return Value

Returns OK when the setting is successful.

Example

redis 127.0.0.1:6379> SETEX mykey 60 redis
OK
redis 127.0.0.1:6379> TTL mykey
60
redis 127.0.0.1:6379> GET mykey
"redis

Redis String (string)

Other Extensions