entry

package
v12.2.10 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {

	// when `Reset` this value is reseting to time.Now(),
	// it's used to send the "Last-Modified" header,
	// some clients may need it.
	LastModified time.Time
	// contains filtered or unexported fields
}

Entry is the cache entry contains the expiration datetime and the response

func (*Entry) Response

func (e *Entry) Response() *Response

Response returns the cached response as it's.

type Pool added in v12.2.8

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

Pool is the context pool, it's used inside router and the framework by itself.

func NewPool added in v12.2.8

func NewPool() *Pool

NewPool creates and returns a new context pool.

func (*Pool) Acquire added in v12.2.8

func (c *Pool) Acquire(lifeDuration time.Duration, r *Response, onExpire func()) *Entry

Acquire returns an Entry from pool. See Release.

func (*Pool) Release added in v12.2.8

func (c *Pool) Release(e *Entry)

Release can be called by custom stores to release an entry.

type Response

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

Response is the cached response will be send to the clients its fields set at runtime on each of the non-cached executions non-cached executions = first execution, and each time after cache expiration datetime passed.

func NewResponse added in v12.2.8

func NewResponse(statusCode int, headers http.Header, body []byte) *Response

NewResponse returns a new cached Response.

func (*Response) Body

func (r *Response) Body() []byte

Body returns contents will be served by the cache handler.

func (*Response) Bytes added in v12.2.8

func (r *Response) Bytes() []byte

Bytes returns a copy of the cached response body.

func (*Response) Headers

func (r *Response) Headers() http.Header

Headers returns the total headers of the cached response.

func (*Response) Read added in v12.2.8

func (r *Response) Read(b []byte) (int, error)

Read implements the io.Reader interface.

func (*Response) SetBody added in v12.2.8

func (r *Response) SetBody(body []byte)

SetBody consumes "b" and sets the body of the cached response.

func (*Response) SetHeaders added in v12.2.8

func (r *Response) SetHeaders(h http.Header)

SetHeaders sets a clone of headers of the cached response.

func (*Response) SetStatusCode added in v12.2.8

func (r *Response) SetStatusCode(statusCode int)

SetStatusCode sets a valid status code.

func (*Response) StatusCode

func (r *Response) StatusCode() int

StatusCode returns a valid status code.

type Store added in v12.2.8

type Store interface {
	// Get returns an entry based on its key.
	Get(key string) *Entry
	// Set sets an entry based on its key.
	Set(key string, e *Entry)
	// Delete deletes an entry based on its key.
	Delete(key string)
}

Store is the interface which is responsible to store the cache entries.

func NewMemStore added in v12.2.8

func NewMemStore() Store

NewMemStore returns a new in-memory store for the cache entries.

Jump to

Keyboard shortcuts

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