Sha256: a71794228c3a41d808d5a02a8673d2784cda2a8054303a83a69f574ae2bae9dd
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
class Redis class MarshaledClient < Client def marshalled_set(key, val, options = nil) val = marshal_value(val, options) if expires_in = expires_in(options) set_with_expire key, val, expires_in else set key, val end end def marshalled_setnx(key, val, options = nil) val = marshal_value(val, options) if expires_in = expires_in(options) setnx_with_expire key, val, expires_in else setnx key, val end end def setnx_with_expire(key, value, ttl) multi do setnx(key, val) expire(key, expires_in) end end def marshalled_get(key, options = nil) result = call_command([:get, key]) result = Marshal.load result if unmarshal?(result, options) result end private def marshal_value(val, options) raw?(options) ? val : Marshal.dump(val) end def unmarshal?(result, options) result && result.size > 0 && !raw?(options) end def raw?(options) options && options[:raw] end def expires_in(options) if options # Rack::Session Merb Rails/Sinatra options[:expire_after] || options[:expires_in] || options[:expire_in] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
redis-store-0.3.9 | lib/redis/marshaled_client.rb |
redis-store-0.3.8 | lib/redis/marshaled_client.rb |