Easy Tutorial
❮ Keys Randomkey Server Client Getname ❯

Redis Setex Command

Redis Strings

The Redis Setex command sets the value of a key with an expiration time. 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 if 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 Strings

❮ Keys Randomkey Server Client Getname ❯