# File lib/redis/store/marshalling.rb, line 16 def get(key, options = nil) _unmarshal super(key), options end
# File lib/redis/store/marshalling.rb, line 20 def mget(*keys) options = keys.flatten.pop if keys.flatten.last.is_a?(Hash) super(*keys).map do |result| _unmarshal result, options end end
# File lib/redis/store/marshalling.rb, line 4 def set(key, value, options = nil) _marshal(value, options) { |value| super encode(key), encode(value), options } end
# File lib/redis/store/marshalling.rb, line 12 def setex(key, expiry, value, options = nil) _marshal(value, options) { |value| super encode(key), expiry, encode(value), options } end
# File lib/redis/store/marshalling.rb, line 8 def setnx(key, value, options = nil) _marshal(value, options) { |value| super encode(key), encode(value), options } end
# File lib/redis/store/marshalling.rb, line 28 def _marshal(val, options) yield marshal?(options) ? Marshal.dump(val) : val end
# File lib/redis/store/marshalling.rb, line 32 def _unmarshal(val, options) unmarshal?(val, options) ? Marshal.load(val) : val end
# File lib/redis/store/marshalling.rb, line 45 def encode(string) string.to_s.force_encoding(Encoding::BINARY) end
# File lib/redis/store/marshalling.rb, line 36 def marshal?(options) !(options && options[:raw]) end
# File lib/redis/store/marshalling.rb, line 40 def unmarshal?(result, options) result && result.size > 0 && marshal?(options) end