Redis 为给定 key 设置生存时间 命令:EXPIREAT

EXPIREAT key timestamp

EXPIREAT 的作用和 EXPIRE 类似,都用于为 key 设置生存时间。

不同在于 EXPIREAT 命令接受的时间参数是 UNIX 时间戳(unix timestamp)。

 

可用版本:

= 1.2.0

 

时间复杂度:

O(1)

 

返回值:

如果生存时间设置成功,返回 1 。

当 key 不存在或没办法设置生存时间,返回 0 。

 

实例:

redis> SET cache www.google.com

OK

 

redis> EXPIREAT cache 1355292000 # 这个 key 将在 2012.12.12 过期

(integer) 1

 

redis> TTL cache

(integer) 45081860

付杰
  • ¥ 69.0元
  • 市场价:99.0元
  • ¥ 298.0元
  • 市场价:498.0元
  • ¥ 198.0元
  • 市场价:398.0元
  • ¥ 45.0元
  • 市场价:45.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: