EXPIREAT Unix timestamp

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Delete a key automatically at a Unix timestamp

Usage: expireat key timestamp [type]
📍 type is one of string/list/set/zset/hash/stream.
      The type argument was added in ent811. Please use it.

Example

Command>set key value
Result>1
Command>expireat key 1534055697 string
Result>1
Command>ttl key string
Result>3
Command>ttl key string
Result>-2
Command>get key
Result>(nil)

View animation



Overwriting with SET removes expire time

If SET is run on the same key after expire time is set, expire time is removed and the key is not deleted.
Such commands include set, getset.
Commands such as incr, lpush, sadd, zadd, and hset are not affected.

Example

Command>set key value
Result>1
Command>expireat key 1534055732 string
Result>1
Command>ttl key string
Result>3
Command>set key new_value
Result>1
Command>ttl key string
Result>-1
Command>get key
Result>new_value

View animation



RENAME does not remove expire time

Changing the key name does not remove expire time.

Example

Command>set key value
Result>1
Command>expireat key 1534055760 string
Result>1
Command>rename key new_key string
Result>OK
Command>ttl key string
Result>-2
Command>get key
Result>(nil)

View animation



Syntax

EXPIREAT key timestamp [type]

  • Available since version 1.2.0.
  • Time complexity is O(1).
  • ent811 type added.
Related commands SETEX, TTL, PERSIST, PSETEX, EXPIREAT, PEXPIRE, PEXPIREAT, PTTL
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< EXPIRE EXPIREAT TTL >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.