Class: DCell::Registry::MonetaAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/dcell/registries/moneta_adapter.rb

Defined Under Namespace

Classes: Registry

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MonetaAdapter

Returns a new instance of MonetaAdapter.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dcell/registries/moneta_adapter.rb', line 7

def initialize(options)
  # Convert all options to symbols :/
  options = options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }

  @env = options[:env] || 'production'
  @namespace = options[:namespace] || "dcell_#{@env}"

  # We might want to use something like a TieredCache later..
  # Memory + BasicFile..
  # @moneta = Moneta::TieredCache.new options
  @moneta = Moneta::Memory.new options

  @node_registry   = Registry.new(@moneta, :nodes)
  @global_registry = Registry.new(@moneta, :globals)
end

Instance Method Details

#clear_globalsObject



58
# File 'lib/dcell/registries/moneta_adapter.rb', line 58

def clear_globals;          @global_registry.clear end

#clear_nodesObject



53
# File 'lib/dcell/registries/moneta_adapter.rb', line 53

def clear_nodes;             @node_registry.clear end

#get_global(key) ⇒ Object



55
# File 'lib/dcell/registries/moneta_adapter.rb', line 55

def get_global(key);        @global_registry.get(key) end

#get_node(node_id) ⇒ Object



50
# File 'lib/dcell/registries/moneta_adapter.rb', line 50

def get_node(node_id);       @node_registry.get(node_id) end

#global_keysObject



57
# File 'lib/dcell/registries/moneta_adapter.rb', line 57

def global_keys;            @global_registry.global_keys end

#nodesObject



52
# File 'lib/dcell/registries/moneta_adapter.rb', line 52

def nodes;                   @node_registry.nodes end

#set_global(key, value) ⇒ Object



56
# File 'lib/dcell/registries/moneta_adapter.rb', line 56

def set_global(key, value); @global_registry.set(key, value) end

#set_node(node_id, addr) ⇒ Object



51
# File 'lib/dcell/registries/moneta_adapter.rb', line 51

def set_node(node_id, addr); @node_registry.set(node_id, addr) end