Class: Rhinestone::Cache
- Inherits:
-
Object
- Object
- Rhinestone::Cache
- Defined in:
- lib/rhinestone/cache.rb
Defined Under Namespace
Classes: KeyNotFound
Instance Method Summary collapse
Instance Method Details
#get(url) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rhinestone/cache.rb', line 13 def get(url) status = get!("status:#{url}").to_i headers = YAML.load(get!("headers:#{url}")) body = get!("body:#{url}") return Rhinestone::Response.new(status, headers, body) rescue KeyNotFound return nil end |
#set(url, response) ⇒ Object
7 8 9 10 11 |
# File 'lib/rhinestone/cache.rb', line 7 def set(url, response) cache_backend.set("status:#{url}", response.status.to_s) cache_backend.set("headers:#{url}", response.headers.to_yaml) cache_backend.set("body:#{url}", response.body) end |