Documentation ¶
Overview ¶
Package ghcache implements an HTTP cache optimized for caching responses from the GitHub API (https://api.github.com).
Specifically, it enforces a cache policy that revalidates every cache hit with a conditional request to upstream regardless of cache entry freshness because conditional requests for unchanged resources don't cost any API tokens!!! See: https://developer.github.com/v3/#conditional-requests
It also provides request coalescing and prometheus instrumentation.
Index ¶
Constants ¶
const ( ModeError = "ERROR" // internal error handling request ModeNoStore = "NO-STORE" // response not cacheable ModeMiss = "MISS" // not in cache, request proxied and response cached. ModeChanged = "CHANGED" // cache value invalid: resource changed, cache updated // The modes below are the happy cases in which the request is fulfilled for // free (no API tokens used). ModeCoalesced = "COALESCED" // coalesced request, this is a copied response ModeRevalidated = "REVALIDATED" // cached value revalidated and returned )
Cache response modes describe how ghcache fulfilled a request.
Variables ¶
This section is empty.
Functions ¶
func NewDiskCache ¶
func NewDiskCache(delegate http.RoundTripper, cacheDir string, cacheSizeGB int) http.RoundTripper
NewDiskCache creates a GitHub cache RoundTripper that is backed by a disk cache.
func NewFromCache ¶
func NewFromCache(delegate http.RoundTripper, cache httpcache.Cache) http.RoundTripper
NewFromCache creates a GitHub cache RoundTripper that is backed by the specified httpcache.Cache implementation.
func NewMemCache ¶
func NewMemCache(delegate http.RoundTripper) http.RoundTripper
NewMemCache creates a GitHub cache RoundTripper that is backed by a memory cache.
Types ¶
This section is empty.