Proper fix for #429

This commit is contained in:
erwanlr
2014-03-21 09:50:57 +01:00
parent a1add0cfdb
commit 3ca79bebc7
2 changed files with 3 additions and 14 deletions

View File

@@ -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"

View File

@@ -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