Module: Typhoeus::Request::Cacheable
- Included in:
- Typhoeus::Request
- Defined in:
- lib/typhoeus/request/cacheable.rb
Overview
Instance Method Summary collapse
- #cache_ttl ⇒ Object
- #cacheable? ⇒ Boolean
- #cached_response ⇒ Object
- #response=(response) ⇒ Object
- #run ⇒ Object
Instance Method Details
#cache_ttl ⇒ Object
26 27 28 |
# File 'lib/typhoeus/request/cacheable.rb', line 26 def cache_ttl [:cache_ttl] end |
#cacheable? ⇒ Boolean
9 10 11 |
# File 'lib/typhoeus/request/cacheable.rb', line 9 def cacheable? cache end |
#cached_response ⇒ Object
22 23 24 |
# File 'lib/typhoeus/request/cacheable.rb', line 22 def cached_response cacheable? && cache.get(self) end |
#response=(response) ⇒ Object
4 5 6 7 |
# File 'lib/typhoeus/request/cacheable.rb', line 4 def response=(response) cache.set(self, response) if cacheable? && !response.cached? super end |
#run ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/typhoeus/request/cacheable.rb', line 13 def run if response = cached_response response.cached = true finish(response) else super end end |