diff --git a/Gemfile b/Gemfile index be4fea17..f02b18b7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "typhoeus", "=0.6.7" +gem "typhoeus", "~>0.6.8" gem "nokogiri" gem "json" gem "terminal-table" diff --git a/lib/common/typhoeus_cache.rb b/lib/common/typhoeus_cache.rb index e745d0f8..68c63553 100644 --- a/lib/common/typhoeus_cache.rb +++ b/lib/common/typhoeus_cache.rb @@ -2,25 +2,14 @@ require 'common/cache_file_store' -# Implementaion of a cache_key (Typhoeus::Request#hash has too many options) -module Typhoeus - class Request - module Cacheable - def cache_key - Digest::SHA2.hexdigest("#{url}-#{options[:body]}-#{options[:method]}")[0..32] - end - end - end -end - class TyphoeusCache < CacheFileStore def get(request) - read_entry(request.cache_key) + read_entry(request.hash.to_s) end def set(request, response) - write_entry(request.cache_key, response, request.cache_ttl) + write_entry(request.hash.to_s, response, request.cache_ttl) end end