api#get should cache response body instead of response object
Closed this issue · 3 comments
mbrung commented
api.rb:177
onwards reads:
api_cache.get_or_set(cache_key, nil, 5) {
res = http_client.get(url, data, 'Accept' => 'application/json')
case res.code
when '200'
res
and later, line 207 onwards:
resp = get(url, access_token, http_client, api_cache)
json = JSON.load(resp.body)
This works with an in-memory cache, as the actual object is stored in memory.
This construct does not allow us to use a Redis-based cache, as Redis will store the string representation of the HTTP client's response (e.g. Net::HTTPOK
) instead of the actual response's body.
Suggested change: have line 181 return res.body
.
srenault commented
Ok thanks for reporting this issue. A fix will be included in the next release!
francois2metz commented
Can be closed now.