Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Setex command

Redis Setex command

Redis string

The Redis Setex command sets the value and expiration time for a specified key. If the key already exists, the SETEX command replaces 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 Version

= 2.0.0

Return Value

Returns OK on success.

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