Method: Redis::Commands::Keys#expire

Defined in:
lib/redis/commands/keys.rb

#expire(key, seconds, nx: nil, xx: nil, gt: nil, lt: nil) ⇒ Boolean

Set a key's time to live in seconds.



82
83
84
85
86
87
88
89
90
# File 'lib/redis/commands/keys.rb', line 82

def expire(key, seconds, nx: nil, xx: nil, gt: nil, lt: nil)
  args = [:expire, key, Integer(seconds)]
  args << "NX" if nx
  args << "XX" if xx
  args << "GT" if gt
  args << "LT" if lt

  send_command(args, &Boolify)
end