Class: DCell::Registry::RedisAdapter::GlobalRegistry
- Inherits:
-
Object
- Object
- DCell::Registry::RedisAdapter::GlobalRegistry
- Defined in:
- lib/dcell/registries/redis_adapter.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #get(key) ⇒ Object
-
#global_keys ⇒ Object
The keys to all globals in the system.
-
#initialize(redis) ⇒ GlobalRegistry
constructor
A new instance of GlobalRegistry.
-
#set(key, value) ⇒ Object
Set a global value.
Constructor Details
#initialize(redis) ⇒ GlobalRegistry
Returns a new instance of GlobalRegistry.
57 58 59 |
# File 'lib/dcell/registries/redis_adapter.rb', line 57 def initialize(redis) @redis = redis end |
Instance Method Details
#clear ⇒ Object
77 78 79 |
# File 'lib/dcell/registries/redis_adapter.rb', line 77 def clear @redis.del 'globals' end |
#get(key) ⇒ Object
61 62 63 64 |
# File 'lib/dcell/registries/redis_adapter.rb', line 61 def get(key) string = @redis.hget 'globals', key.to_s Marshal.load string if string end |
#global_keys ⇒ Object
The keys to all globals in the system
73 74 75 |
# File 'lib/dcell/registries/redis_adapter.rb', line 73 def global_keys @redis.hkeys 'globals' end |
#set(key, value) ⇒ Object
Set a global value
67 68 69 70 |
# File 'lib/dcell/registries/redis_adapter.rb', line 67 def set(key, value) string = Marshal.dump value @redis.hset 'globals', key.to_s, string end |