module Redis::Store::Ttl
Public Instance Methods
set(key, value, options = nil)
click to toggle source
Calls superclass method
# File lib/redis/store/ttl.rb, line 4 def set(key, value, options = nil) if ttl = expires_in(options) setex(key, ttl.to_i, value, :raw => true) else super(key, value) end end
setnx(key, value, options = nil)
click to toggle source
Calls superclass method
# File lib/redis/store/ttl.rb, line 12 def setnx(key, value, options = nil) if ttl = expires_in(options) setnx_with_expire(key, value, ttl.to_i) else super(key, value) end end
Protected Instance Methods
setnx_with_expire(key, value, ttl)
click to toggle source
# File lib/redis/store/ttl.rb, line 21 def setnx_with_expire(key, value, ttl) multi do setnx(key, value, :raw => true) expire(key, ttl) end end
Private Instance Methods
expires_in(options)
click to toggle source
# File lib/redis/store/ttl.rb, line 29 def expires_in(options) if options # Rack::Session Merb Rails/Sinatra options[:expire_after] || options[:expires_in] || options[:expire_in] end end