Class: Prefetcher::HttpMemoizer
- Inherits:
-
Object
- Object
- Prefetcher::HttpMemoizer
- Defined in:
- lib/prefetcher/http_memoizer.rb
Instance Attribute Summary collapse
-
#redis_connection ⇒ Object
readonly
Returns the value of attribute redis_connection.
Instance Method Summary collapse
-
#get_list ⇒ Object
Get all memoized URLs.
-
#initialize(params = {}) ⇒ HttpMemoizer
constructor
A new instance of HttpMemoizer.
-
#push(url) ⇒ Object
Add URL to memoized list.
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_connection ⇒ Object (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_list ⇒ Object
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 |