Class: DCell::Registry::CassandraAdapter::GlobalRegistry

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

Instance Method Summary collapse

Constructor Details

#initialize(cass, cf) ⇒ GlobalRegistry

Returns a new instance of GlobalRegistry.



95
96
97
98
# File 'lib/dcell/registries/cassandra_adapter.rb', line 95

def initialize(cass, cf)
  @cass = cass
  @cf = cf
end

Instance Method Details

#clear_allObject



116
117
118
# File 'lib/dcell/registries/cassandra_adapter.rb', line 116

def clear_all
  @cass.del @cf, "globals"
end

#get(key) ⇒ Object



100
101
102
103
# File 'lib/dcell/registries/cassandra_adapter.rb', line 100

def get(key)
  string = @cass.get @cf, "globals", key.to_s
  Marshal.load string if string
end

#global_keysObject

The keys to all globals in the system



112
113
114
# File 'lib/dcell/registries/cassandra_adapter.rb', line 112

def global_keys
  @cass.get(@cf, "globals").keys
end

#set(key, value) ⇒ Object

Set a global value



106
107
108
109
# File 'lib/dcell/registries/cassandra_adapter.rb', line 106

def set(key, value)
  string = Marshal.dump value
  @cass.insert @cf, "globals", { key.to_s => string }
end