module Typhoeus::Request::Cacheable

def cache_ttl

def cache_ttl
  options[:cache_ttl]
end

def cacheable?

def cacheable?
  Typhoeus::Config.cache
end

def response=(response)

def response=(response)
  Typhoeus::Config.cache.set(self, response) if cacheable? && !response.cached?
  super
end

def run

def run
  if cacheable? && response = Typhoeus::Config.cache.get(self)
    response.cached = true
    finish(response)
  else
    super
  end
end