cache

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheNotFound = errors.New("cache not found")

ErrCacheNotFound is returned when there is no matching cache.

Functions

This section is empty.

Types

type Cache

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

Cache

func New

func New(opts ...CacheOption) *Cache

func (*Cache) Delete

func (c *Cache) Delete(req *http.Request, opts *DeleteOptions) error

Delete removes the Response object from the cache. This method only purges content of the cache in the data center that the Worker was invoked. Returns ErrCacheNotFount if the response was not cached.

func (*Cache) Match

func (c *Cache) Match(req *http.Request, opts *MatchOptions) (*http.Response, error)

Match returns the response object keyed to that request. docs: https://developers.cloudflare.com/workers/runtime-apis/cache/#match

func (*Cache) Put

func (c *Cache) Put(req *http.Request, res *http.Response) error

Put attempts to add a response to the cache, using the given request as the key. Returns an error for the following conditions - the request passed is a method other than GET. - the response passed has a status of 206 Partial Content. - Cache-Control instructs not to cache or if the response is too large. docs: https://developers.cloudflare.com/workers/runtime-apis/cache/#put

type CacheOption

type CacheOption func(*Cache)

CacheOption

func WithNamespace

func WithNamespace(namespace string) CacheOption

WithNamespace

type DeleteOptions

type DeleteOptions struct {
	// IgnoreMethod - Consider the request method a GET regardless of its actual value.
	IgnoreMethod bool
}

DeleteOptions represents the options of the Delete method.

type MatchOptions

type MatchOptions struct {
	// IgnoreMethod - Consider the request method a GET regardless of its actual value.
	IgnoreMethod bool
}

MatchOptions represents the options of the Match method.

Jump to

Keyboard shortcuts

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