Sha256: d61001cf67607faa675354412acfc754842cfc061e859f6484e73cbf382afa71
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
class Redis class Store < self module Ttl def set(key, value, options = nil) if ttl = expires_in(options) setex(key, ttl.to_i, value, :raw => true) else super(key, value, options) end end def setnx(key, value, options = nil) if ttl = expires_in(options) setnx_with_expire(key, value, ttl.to_i, options) else super(key, value) end end protected def setnx_with_expire(key, value, ttl, options = {}) with_multi_or_pipelined(options) do setnx(key, value, :raw => true) expire(key, ttl) end end private def expires_in(options) if options # Rack::Session Merb Rails/Sinatra options[:expire_after] || options[:expires_in] || options[:expire_in] end end def with_multi_or_pipelined(options, &block) return pipelined(&block) if options[:avoid_multi_commands] multi(&block) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redis-store-1.6.0 | lib/redis/store/ttl.rb |
redis-store-1.5.0 | lib/redis/store/ttl.rb |
redis-store-1.4.1 | lib/redis/store/ttl.rb |