Keys Expire
# Redis Expire Command
[!(#) Redis Keys](#)
The Redis Expire command sets the expiration time for a key. After expiration, the key becomes unavailable. The time unit is seconds.
### Syntax
The basic syntax of the Redis Expire command is as follows:
redis 127.0.0.1:6379> Expire KEY_NAME TIME_IN_SECONDS
### Available Versions
>= 1.0.0
### Return Value
Returns 1 if the operation succeeds. Returns 0 if the key does not exist or if the expiration time cannot be set for the key (for example, when attempting to update the expiration time of a key in Redis versions earlier than 2.1.3).
### Example
First, create a key and assign a value:
redis 127.0.0.1:6379> SET runooobkey redis OK
Set an expiration time for the key:
redis 127.0.0.1:6379> EXPIRE runooobkey 60(integer) 1
In the above example, we set the expiration time for the key `runooobkey` to 1 minute; after 1 minute, this key will be automatically deleted.
[!(#) Redis Keys](#)
YouTip