Class: Zemanta::Fetcher::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/zemanta/fetcher/cache.rb,
lib/zemanta/fetcher/cache/key.rb,
lib/zemanta/fetcher/cache/response.rb,
lib/zemanta/fetcher/cache/null_response.rb

Defined Under Namespace

Classes: Key, NullResponse, Response

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Cache

Returns a new instance of Cache.



4
5
6
# File 'lib/zemanta/fetcher/cache.rb', line 4

def initialize(opts = {})
  @key = Key.new(opts).to_s
end

Instance Method Details

#fetchObject



8
9
10
# File 'lib/zemanta/fetcher/cache.rb', line 8

def fetch
  fetch_from_storage(@key).to_s
end

#save(response) ⇒ Object



12
13
14
# File 'lib/zemanta/fetcher/cache.rb', line 12

def save(response)
  storage[@key] = Response.new(response) unless storage[@key]
end