cache

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseCache

type ResponseCache struct {
	GetKey func(r *http.Request) string
	// contains filtered or unexported fields
}

func NewResponseCache

func NewResponseCache(expiration, cleanup time.Duration) *ResponseCache

func (*ResponseCache) Get

func (c *ResponseCache) Get(r *http.Request) (key string, resp *http.Response, ok bool, err error)

Get attempts to retrieve a http.Response from the cache for the request r. On return, key holds the key used to store the response (to be passed to Put), resp contains the cached response (if found) and ok indicates if the response was found in the cache.

Clients must call resp.Body.Close when finished reading resp.Body. After that call, clients can inspect resp.Trailer to find key/value pairs included in the response trailer.

func (*ResponseCache) Put

func (c *ResponseCache) Put(key string, _ *http.Request, resp *http.Response) error

Put stores a http.Response in the case, using the provided key. The request is currently not used.

type RoundTripper

type RoundTripper struct {
	// contains filtered or unexported fields
}

func NewRoundTripper

func NewRoundTripper(expiry, cleanup time.Duration, next http.RoundTripper) *RoundTripper

func (*RoundTripper) Collect

func (r *RoundTripper) Collect(ch chan<- prometheus.Metric)

func (*RoundTripper) Describe

func (r *RoundTripper) Describe(ch chan<- *prometheus.Desc)

func (*RoundTripper) RoundTrip

func (r *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL