From 3ca79bebc77e5d349aa114cf5ecf63ea53c717eb Mon Sep 17 00:00:00 2001 From: erwanlr Date: Fri, 21 Mar 2014 09:50:57 +0100 Subject: [PATCH] Proper fix for #429 --- Gemfile | 2 +- lib/common/typhoeus_cache.rb | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) 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