Module: PuavoRest::LocalStore
- Included in:
- ExternalService, Host, LtspServer, School, Session
- Defined in:
- lib/local_store.rb
Overview
Simple writeable local store mixin
This mixins adds simple shortcuts for redis set and get. The class in which this mixin is included to must implemented a instance_key method which uniquely identifies the instance
Defined Under Namespace
Modules: ClassMethods
Class Method Summary (collapse)
-
+ (Object) close_connection
Close the Redis connection.
- + (Object) included(base)
Instance Method Summary (collapse)
- - (Object) local_store
- - (Object) local_store_del(key)
- - (Object) local_store_expire(key, time)
- - (Object) local_store_get(key)
- - (Object) local_store_set(key, val)
Class Method Details
+ (Object) close_connection
Close the Redis connection
41 42 43 44 45 46 |
# File 'lib/local_store.rb', line 41 def self.close_connection if c = Thread.current[:redis_connection] c.quit Thread.current[:redis_connection] = nil end end |
+ (Object) included(base)
36 37 38 |
# File 'lib/local_store.rb', line 36 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
- (Object) local_store
18 19 20 |
# File 'lib/local_store.rb', line 18 def local_store self.class.local_store end |
- (Object) local_store_del(key)
28 29 30 |
# File 'lib/local_store.rb', line 28 def local_store_del(key) local_store.del("#{ instance_key }:#{ key }") end |
- (Object) local_store_expire(key, time)
31 32 33 |
# File 'lib/local_store.rb', line 31 def local_store_expire(key, time) local_store.expire("#{ instance_key }:#{ key }", time) end |
- (Object) local_store_get(key)
25 26 27 |
# File 'lib/local_store.rb', line 25 def local_store_get(key) local_store.get("#{ instance_key }:#{ key }") end |
- (Object) local_store_set(key, val)
22 23 24 |
# File 'lib/local_store.rb', line 22 def local_store_set(key, val) local_store.set("#{ instance_key }:#{ key }", val) end |