English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Setex Command

Redis Strings (string)

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

Syntax

Basic Syntax of Redis Setex Command

redis 127.0.0.1:6379> SETEX KEY_NAME TIMEOUT VALUE

Available Versions

>= 2.0.0

Return Values

Returns OK when the setting is successful.

Online Examples

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 Strings (string)