Class: Smoke::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/smoke/cache.rb

Class Method Summary collapse

Class Method Details

.clear!Object

Clear all your request caches



22
23
24
# File 'lib/smoke/cache.rb', line 22

def clear!
  cache.clear
end

.enabled?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/smoke/cache.rb', line 17

def enabled?
  Smoke.config[:cache][:enabled]
end

.fetch(uri, options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/smoke/cache.rb', line 4

def fetch(uri, options)  
  output = (enabled?) ? read(uri) : query(uri, options)
  
  unless output.keys.any?
    Smoke.log.info "Cache miss"
    output = query(uri, options)
  end
  
  output
rescue
  query(uri, options)
end