Class: FnordMetric::Cache
- Inherits:
-
Object
- Object
- FnordMetric::Cache
- Defined in:
- lib/fnordmetric/cache.rb
Class Method Summary collapse
- .get(cache_key) ⇒ Object
-
.store!(cache_key, data) ⇒ Object
field :cache_key, :type => String field :data, :type => Hash.
Class Method Details
.get(cache_key) ⇒ Object
14 15 16 17 18 |
# File 'lib/fnordmetric/cache.rb', line 14 def self.get(cache_key) item = self.where(:cache_key => cache_key).last return nil unless item item.data.keys == ["value"] ? item.data["value"] : item.data end |
.store!(cache_key, data) ⇒ Object
field :cache_key, :type => String
field :data, :type => Hash
9 10 11 12 |
# File 'lib/fnordmetric/cache.rb', line 9 def self.store!(cache_key, data) data = { :value => data } unless data.is_a?(Hash) self.create(:cache_key => cache_key, :data => data) end |