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_all ⇒ 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.
65 66 67 |
# File 'lib/dcell/registries/redis_adapter.rb', line 65 def initialize(redis) @redis = redis end |
Instance Method Details
#clear_all ⇒ Object
85 86 87 |
# File 'lib/dcell/registries/redis_adapter.rb', line 85 def clear_all @redis.del 'globals' end |
#get(key) ⇒ Object
69 70 71 72 |
# File 'lib/dcell/registries/redis_adapter.rb', line 69 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
81 82 83 |
# File 'lib/dcell/registries/redis_adapter.rb', line 81 def global_keys @redis.hkeys 'globals' end |
#set(key, value) ⇒ Object
Set a global value
75 76 77 78 |
# File 'lib/dcell/registries/redis_adapter.rb', line 75 def set(key, value) string = Marshal.dump value @redis.hset 'globals', key.to_s, string end |