Skip to content

[docs] Document API caching behavior #7482

Description

@mattsb42-aws

Describe the feature or problem you’d like to solve

I manage quite a few GitHub orgs and periodically need to do one-off data collection about those orgs, the repos they contain, and the teams within them. Often times, the easiest solution to these sorts of one-off data collection problems is to squish gh and jq together in an unholy bash oneliner. However, actually running through the queries I want, across thousands of repositories, both takes a while to run and churns through API rate limit tokens.

My solution to this is a wrapper that caches all responses from gh locally, refreshing the cache contents if they contain a rate limit response or if I force it to.

Recently, I noticed that the gh api subcommand accepts a --cache option flag. This piqued my interest. "Maybe I can toss this one-off wrapper and just use the built-in cache", says I to myself. Unfortunately, I can't find any documentation that explains precisely what this control does or what valid configuration values are. From digging through the code, it appears that this value is parsed by time.ParseDuration, which hints at the valid configuration values, and then sets a header that appears to be passed without other handling to http.Client. Go is not my forte, so it's likely I'm missing something, but I can't figure out from an hour or so diving through the code, what in fact this caching feature does or how it works.

Proposed solution

As a first step, documenting how the feature works would be wonderful. If it does everything I need, then cool, end of discussion. :) If it doesn't, then I'll know where to start discussing adding new capabilities (specifically: the ability to force a cache update is critical.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions