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.



87
88
89
90
# File 'lib/dcell/registries/cassandra_adapter.rb', line 87

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

Instance Method Details

#clearObject



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

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

#get(key) ⇒ Object



92
93
94
95
# File 'lib/dcell/registries/cassandra_adapter.rb', line 92

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



104
105
106
# File 'lib/dcell/registries/cassandra_adapter.rb', line 104

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

#set(key, value) ⇒ Object

Set a global value



98
99
100
101
# File 'lib/dcell/registries/cassandra_adapter.rb', line 98

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