module Redis::Store::Marshalling
Public Instance Methods
get(key, options = nil)
click to toggle source
Calls superclass method
# File lib/redis/store/marshalling.rb, line 16 def get(key, options = nil) _unmarshal super(key), options end
mget(*keys)
click to toggle source
Calls superclass method
# File lib/redis/store/marshalling.rb, line 20 def mget(*keys) options = keys.pop if keys.last.is_a?(Hash) super(*keys).map do |result| _unmarshal result, options end end
set(key, value, options = nil)
click to toggle source
Calls superclass method
# 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
setex(key, expiry, value, options = nil)
click to toggle source
Calls superclass method
# 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
setnx(key, value, options = nil)
click to toggle source
Calls superclass method
# 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
Private Instance Methods
_marshal(val, options) { |marshal?(options) ? dump: val| ... }
click to toggle source
# File lib/redis/store/marshalling.rb, line 28 def _marshal(val, options) yield marshal?(options) ? Marshal.dump(val) : val end
_unmarshal(val, options)
click to toggle source
# File lib/redis/store/marshalling.rb, line 32 def _unmarshal(val, options) unmarshal?(val, options) ? Marshal.load(val) : val end
encode(string)
click to toggle source
# File lib/redis/store/marshalling.rb, line 45 def encode(string) key = string.to_s.dup key.force_encoding(Encoding::BINARY) end
marshal?(options)
click to toggle source
# File lib/redis/store/marshalling.rb, line 36 def marshal?(options) !(options && options[:raw]) end
unmarshal?(result, options)
click to toggle source
# File lib/redis/store/marshalling.rb, line 40 def unmarshal?(result, options) result && result.size > 0 && marshal?(options) end