Class: Split::Cache
- Inherits:
-
Object
- Object
- Split::Cache
- Defined in:
- lib/split/cache.rb
Class Method Summary collapse
Class Method Details
.clear ⇒ Object
6 7 8 |
# File 'lib/split/cache.rb', line 6 def self.clear @cache = nil end |
.clear_key(key) ⇒ Object
22 23 24 25 26 |
# File 'lib/split/cache.rb', line 22 def self.clear_key(key) @cache&.keys&.each do |namespace| @cache[namespace]&.delete(key) end end |
.fetch(namespace, key) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/split/cache.rb', line 10 def self.fetch(namespace, key) return yield unless Split.configuration.cache @cache ||= {} @cache[namespace] ||= {} value = @cache[namespace][key] return value if value @cache[namespace][key] = yield end |