Class: WebCrawler::CacheAdapter::Memory

Inherits:
Base
  • Object
show all
Defined in:
lib/web_crawler/cache_adapter/memory.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#expire_within, #expired?, #prepare_response, #set

Class Attribute Details

.cacheObject

Returns the value of attribute cache.



5
6
7
# File 'lib/web_crawler/cache_adapter/memory.rb', line 5

def cache
  @cache
end

Instance Method Details

#exist?(uri) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/web_crawler/cache_adapter/memory.rb', line 18

def exist? uri
  self.class.cache.key? uri.to_s
end

#get(uri) ⇒ Object



14
15
16
# File 'lib/web_crawler/cache_adapter/memory.rb', line 14

def get uri
  self.class.cache[uri.to_s]
end

#put(response) ⇒ Object



10
11
12
# File 'lib/web_crawler/cache_adapter/memory.rb', line 10

def put response
  response.tap { self.class.cache[response.url.to_s] = super }
end