Class: Restfulie::Client::Feature::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/restfulie/client/feature/cache.rb

Instance Method Summary collapse

Instance Method Details

#execute(flow, request, env) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/restfulie/client/feature/cache.rb', line 3

def execute(flow, request, env)
  found = Restfulie::Client.cache_provider.get([request.host, request.path], request)
  return found if found
  
  resp = flow.continue(request, env)
  if resp.kind_of?(Exception)
    resp
  else
    Restfulie::Client.cache_provider.put([request.host, request.path], request, resp)
    resp
  end
end