Proper fix for #429
This commit is contained in:
2
Gemfile
2
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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user