cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteMetadata

func DeleteMetadata(method string, url url.URL) error

DeleteMetadata - Removes the cache metadata for the requested URL.

func FetchMetadata

func FetchMetadata(method string, url url.URL) ([]string, error)

FetchMetadata - Returns the cache metadata for the requested URL.

func GetVary

func GetVary(headers http.Header) ([]string, error)

GetVary - Returns the content from the Vary HTTP header.

func PurgeMetadata

func PurgeMetadata(url url.URL) error

PurgeMetadata - Purges the cache metadata for the requested URL.

func StorageKey

func StorageKey(method string, url url.URL, meta []string, reqHeaders http.Header) string

StorageKey - Returns the cache key for the requested URL.

func StoreMetadata

func StoreMetadata(method string, url url.URL, meta []string, expiration time.Duration) (bool, error)

StoreMetadata - Saves the cache metadata for the requested URL.

Types

type CacheObj

type CacheObj struct {
	AllowedStatuses []int
	AllowedMethods  []string
	CurrentObj      URIObj
}

CacheObj - Contains cache settings and current cached/cacheable object.

func (CacheObj) IsMethodAllowed

func (c CacheObj) IsMethodAllowed() bool

IsMethodAllowed - Checks if a HTTP method is allowed to be cached.

func (CacheObj) IsStatusAllowed

func (c CacheObj) IsStatusAllowed() bool

IsStatusAllowed - Checks if a status code is allowed to be cached.

func (CacheObj) IsValid

func (c CacheObj) IsValid() (bool, error)

IsValid - Verifies the validity of a cacheable object.

func (CacheObj) PurgeFullPage

func (c CacheObj) PurgeFullPage(method string, url url.URL) (bool, error)

PurgeFullPage - Deletes the whole page response from cache.

func (*CacheObj) RetrieveFullPage

func (c *CacheObj) RetrieveFullPage(method string, url url.URL, reqHeaders http.Header) error

RetrieveFullPage - Retrieves the whole page response from cache.

func (CacheObj) StoreFullPage

func (c CacheObj) StoreFullPage(expiration time.Duration) (bool, error)

StoreFullPage - Stores the whole page response in cache.

type URIObj

type URIObj struct {
	URL             url.URL
	Host            string
	Method          string
	StatusCode      int
	RequestHeaders  http.Header
	ResponseHeaders http.Header
	Content         [][]byte
}

URIObj - Holds details about the response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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