Module: Redis::Store::Serialization
- Defined in:
- lib/redis/store/serialization.rb
Instance Method Summary collapse
- #get(key, options = nil) ⇒ Object
- #mget(*keys, &blk) ⇒ Object
- #mset(*args) ⇒ Object
- #set(key, value, options = nil) ⇒ Object
- #setex(key, expiry, value, options = nil) ⇒ Object
- #setnx(key, value, options = nil) ⇒ Object
Instance Method Details
#get(key, options = nil) ⇒ Object
16 17 18 |
# File 'lib/redis/store/serialization.rb', line 16 def get(key, = nil) _unmarshal super(key), end |
#mget(*keys, &blk) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/redis/store/serialization.rb', line 20 def mget(*keys, &blk) = keys.pop if keys.last.is_a?(Hash) super(*keys) do |reply| reply.map! { |value| _unmarshal value, } blk ? blk.call(reply) : reply end end |
#mset(*args) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/redis/store/serialization.rb', line 28 def mset(*args) = args.pop if args.length.odd? updates = [] args.each_slice(2) do |(key, value)| updates << encode(key) _marshal(value, ) { |v| updates << encode(v) } end super(*updates) end |
#set(key, value, options = nil) ⇒ Object
4 5 6 |
# File 'lib/redis/store/serialization.rb', line 4 def set(key, value, = nil) _marshal(value, ) { |v| super encode(key), encode(v), } end |
#setex(key, expiry, value, options = nil) ⇒ Object
12 13 14 |
# File 'lib/redis/store/serialization.rb', line 12 def setex(key, expiry, value, = nil) _marshal(value, ) { |v| super encode(key), expiry, encode(v), } end |
#setnx(key, value, options = nil) ⇒ Object
8 9 10 |
# File 'lib/redis/store/serialization.rb', line 8 def setnx(key, value, = nil) _marshal(value, ) { |v| super encode(key), encode(v), } end |