http-cache: Index | Files | Directories

package cache

import ""


Package Files


type Adapter Uses

type Adapter interface {
    // Get retrieves the cached response by a given key. It also
    // returns true or false, whether it exists or not.
    Get(key uint64) ([]byte, bool)

    // Set caches a response for a given key until an expiration date.
    Set(key uint64, response []byte, expiration time.Time)

    // Release frees cache for a given key.
    Release(key uint64)

Adapter interface for HTTP cache middleware client.

type Client Uses

type Client struct {
    // contains filtered or unexported fields

Client data structure for HTTP cache middleware.

func NewClient Uses

func NewClient(opts ...ClientOption) (*Client, error)

NewClient initializes the cache HTTP middleware client with the given options.

func (*Client) Middleware Uses

func (c *Client) Middleware(next http.Handler) http.Handler

Middleware is the HTTP cache middleware handler.

type ClientOption Uses

type ClientOption func(c *Client) error

ClientOption is used to set Client settings.

func ClientWithAdapter Uses

func ClientWithAdapter(a Adapter) ClientOption

ClientWithAdapter sets the adapter type for the HTTP cache middleware client.

func ClientWithRefreshKey Uses

func ClientWithRefreshKey(refreshKey string) ClientOption

ClientWithRefreshKey sets the parameter key used to free a request cached response. Optional setting.

func ClientWithTTL Uses

func ClientWithTTL(ttl time.Duration) ClientOption

ClientWithTTL sets how long each response is going to be cached.

type Response Uses

type Response struct {
    // Value is the cached response value.
    Value []byte

    // Header is the cached response header.
    Header http.Header

    // Expiration is the cached response expiration date.
    Expiration time.Time

    // LastAccess is the last date a cached response was accessed.
    // Used by LRU and MRU algorithms.
    LastAccess time.Time

    // Frequency is the count of times a cached response is accessed.
    // Used for LFU and MFU algorithms.
    Frequency int

Response is the cached response data structure.

func BytesToResponse Uses

func BytesToResponse(b []byte) Response

BytesToResponse converts bytes array into Response data structure.

func (Response) Bytes Uses

func (r Response) Bytes() []byte

Bytes converts Response data structure into bytes array.



Package cache imports 11 packages (graph) and is imported by 2 packages. Updated 2018-09-18. Refresh now. Tools for package owners.