Latest web development tutorials

Redis Expire command

Redis key (key)

Redis Expire command is used to set the key expiration time. key will expire no longer available.

grammar

redis Expire basic command syntax is as follows:

redis 127.0.0.1:6379> Expire KEY_NAME TIME_IN_SECONDS

Available versions

> = 1.0.0

return value

Set successfully returned. When the key does not exist or can not set the expiration time for the key (for example, in less than 2.1.3 version of Redis you try to update the key expiration time) returns 0.

Examples

First, create a key and assignment:

redis 127.0.0.1:6379> SET runooobkey redis
OK

Set the expiration time for the key:

redis 127.0.0.1:6379> EXPIRE runooobkey 60
(integer) 1

The above example we set the expiration time of 1 minute is a bond runooobkey, 1 minutes after the key is automatically deleted.

Redis key (key)