class Prefetcher::HttpMemoizer

Attributes

redis_connection[R]

Public Class Methods

new(params = {}) click to toggle source
# File lib/prefetcher/http_memoizer.rb, line 5
def initialize(params = {})
  @redis_connection = params.fetch(:redis_connection, Prefetcher.redis_connection)
end

Public Instance Methods

get_list() click to toggle source

Get all memoized URLs

# File lib/prefetcher/http_memoizer.rb, line 15
def get_list
  redis.smembers cache_key
end
push(url) click to toggle source

Add URL to memoized list

# File lib/prefetcher/http_memoizer.rb, line 10
def push(url)
  redis.sadd(cache_key, url)
end

Protected Instance Methods

cache_key() click to toggle source
# File lib/prefetcher/http_memoizer.rb, line 20
def cache_key
  "urls-list"
end
redis() click to toggle source
# File lib/prefetcher/http_memoizer.rb, line 24
def redis
  Prefetcher.redis_connection
end