Class: RedisStore::MarshalledClient
- Inherits:
-
Redis::Client
- Object
- Redis::Client
- RedisStore::MarshalledClient
- Defined in:
- lib/redis_store/marshalled_client.rb
Instance Method Summary collapse
- #marshalled_get(key, options = nil) ⇒ Object
- #marshalled_set(key, val, options = nil) ⇒ Object
- #marshalled_setnx(key, val, options = nil) ⇒ Object
- #setnx_with_expire(key, value, ttl) ⇒ Object
Instance Method Details
#marshalled_get(key, options = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/redis_store/marshalled_client.rb', line 28 def marshalled_get(key, = nil) result = call_command([:get, key]) result = Marshal.load result if unmarshal?(result, ) result end |
#marshalled_set(key, val, options = nil) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/redis_store/marshalled_client.rb', line 3 def marshalled_set(key, val, = nil) val = marshal_value(val, ) if expires_in = expires_in() set_with_expire(key, val, expires_in) else set(key, val) end end |
#marshalled_setnx(key, val, options = nil) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/redis_store/marshalled_client.rb', line 12 def marshalled_setnx(key, val, = nil) val = marshal_value(val, ) if expires_in = expires_in() setnx_with_expire(key, val, expires_in) else setnx(key, val) end end |
#setnx_with_expire(key, value, ttl) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/redis_store/marshalled_client.rb', line 21 def setnx_with_expire(key, value, ttl) multi do setnx(key, val) expire(key, expires_in) end end |