cache

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Cache

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

func New

func New() *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) Open

func (c *Cache) Open(namespace string) error

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 DeleteOptions

type DeleteOptions struct {
	IgnoreMethod bool
}

type MatchOptions

type MatchOptions struct {
	IgnoreMethod bool
}

Jump to

Keyboard shortcuts

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