swr

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateETag

func GenerateETag(bytes []byte) string

func IsNotModified

func IsNotModified(r *http.Request, etag string) bool

Types

type Cache

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

func NewCache added in v0.0.24

func NewCache(opts CacheOpts) *Cache

func (*Cache) Get

func (c *Cache) Get(r *http.Request) (*ResponseData, error)

type CacheOpts added in v0.0.24

type CacheOpts struct {
	MaxAge           time.Duration
	SWR              time.Duration
	CleanupInterval  time.Duration
	GetterFunc       GetterFunc
	RequestToKeyFunc RequestToKeyFunc
}

type GetterFunc

type GetterFunc func(r *http.Request) ([]byte, error)

type RequestToKeyFunc

type RequestToKeyFunc func(r *http.Request) string

type ResponseData

type ResponseData struct {
	Bytes     []byte
	ETag      string
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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