Skip to content

api#get should cache response body instead of response object #67

Description

@mbrung

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions