Class: Sinbotra::Bot::RedisStore
- Inherits:
-
Object
- Object
- Sinbotra::Bot::RedisStore
- Defined in:
- lib/sinbotra/bot/redis_store.rb
Direct Known Subclasses
Instance Method Summary collapse
- #get(id) ⇒ Object (also: #[])
- #make_key(id) ⇒ Object
- #set(id, obj) ⇒ Object (also: #[]=)
Instance Method Details
#get(id) ⇒ Object Also known as: []
3 4 5 6 |
# File 'lib/sinbotra/bot/redis_store.rb', line 3 def get(id) res = $redis.get(make_key(id)) Marshal.load(res) unless res.nil? end |
#make_key(id) ⇒ Object
15 16 17 |
# File 'lib/sinbotra/bot/redis_store.rb', line 15 def make_key(id) raise NotImplementedError, "make_key needs to be implemented by children" end |
#set(id, obj) ⇒ Object Also known as: []=
9 10 11 12 |
# File 'lib/sinbotra/bot/redis_store.rb', line 9 def set(id, obj) raw = Marshal.dump(obj) $redis.set(make_key(id), raw) end |