TTL seconds

Redis 開発者教育の申込 Redis 定期点検/技術サポート
Redis Technical Support
Redis エンタープライズサーバー
Redis Enterprise Server

残りの expire time(seconds) を照会

使い方は ttl key [type] です。
キーが削除済みなら -2 を返し、expire time が設定されていなければ -1 を返します。
📍 type は string/list/set/zset/hash/stream のいずれかです。
      ent811 から type が追加されました。ぜひ使用してください。

Example

コマンド>set key value
結果>1
コマンド>expire key 5 string
結果>1
コマンド>ttl key string
結果>3
コマンド>ttl key string
結果>-2
コマンド>get key
結果>(nil)


構文

TTL key [type]

  • このコマンドは version 1.0.0 から使用できます。
  • 時間計算量は O(1) です。
  • ent811 で type を追加。
関連コマンド SETEX, TTL, PERSIST, PSETEX, EXPIREAT, PEXPIRE, PEXPIREAT, PTTL
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< EXPIREAT TTL PEXPIRE >>

Email 返事がかかってなれば、メールでお知らせします。