Class: Prefetcher::HttpMemoizer

Inherits:
Object
  • Object
show all
Defined in:
lib/prefetcher/http_memoizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ HttpMemoizer

Returns a new instance of HttpMemoizer.



5
6
7
# File 'lib/prefetcher/http_memoizer.rb', line 5

def initialize(params = {})
  @redis_connection = params.fetch(:redis_connection, Prefetcher.redis_connection)
end

Instance Attribute Details

#redis_connectionObject (readonly)

Returns the value of attribute redis_connection.



3
4
5
# File 'lib/prefetcher/http_memoizer.rb', line 3

def redis_connection
  @redis_connection
end

Instance Method Details

#get_listObject

Get all memoized URLs



15
16
17
# File 'lib/prefetcher/http_memoizer.rb', line 15

def get_list
  redis.smembers cache_key
end

#push(url) ⇒ Object

Add URL to memoized list



10
11
12
# File 'lib/prefetcher/http_memoizer.rb', line 10

def push(url)
  redis.sadd(cache_key, url)
end