Documentation ¶
Index ¶
- Constants
- func ExpandESI(resp *http.Response, esiTags []EsiTag, ...) (*http.Response, error)
- func HTTPResponseFromBytes(b []byte) (*http.Response, error)
- func HTTPResponseToBytes(r *http.Response) ([]byte, error)
- func PrivateKeyFromRequest(r *http.Request, config *Config) string
- func PublicKeyFromRequest(r *http.Request, config *Config) string
- func WildcardCompare(original string, test string) bool
- type Config
- type EsiTag
- type FileStorage
- func (s *FileStorage) Delete() error
- func (s *FileStorage) FetchResponse() (*http.Response, error)
- func (s *FileStorage) GetSize() (int64, error)
- func (s *FileStorage) GetTypeName() string
- func (s *FileStorage) Init(key string, config *Config)
- func (s *FileStorage) StoreResponse(r *http.Response) error
- type Handler
- func (b *Handler) Clean()
- func (b *Handler) Clear()
- func (b *Handler) Fetch(r *http.Request) *Item
- func (b *Handler) Invalidate(req *http.Request)
- func (b *Handler) OnRequest(req *http.Request) (*http.Response, error)
- func (b *Handler) OnResponse(resp *http.Response) (*http.Response, error)
- func (b *Handler) Store(resp *http.Response) (*Item, error)
- type Item
- type MemoryStorage
- func (s *MemoryStorage) Delete() error
- func (s *MemoryStorage) FetchResponse() (*http.Response, error)
- func (s *MemoryStorage) GetSize() (int64, error)
- func (s *MemoryStorage) GetTypeName() string
- func (s *MemoryStorage) Init(key string, config *Config)
- func (s *MemoryStorage) StoreResponse(r *http.Response) error
- type Storage
Constants ¶
const CacheItemFileExtension = ".ccache"
CacheItemFileExtension - file extension to use for
const CacheItemPrivate = "private"
CacheItemPrivate - flag, denotes cache item is private cache
const CacheItemPublic = "public"
CacheItemPublic - flag, denotes cache item is public cache
const CacheStorageFile = "file"
CacheStorageFile - storage handler name for file system handler
const CacheStorageMemory = "memory"
CacheStorageMemory - storage handler name for memory handler
const VersionNo = 1
VersionNo - current version of this extension
Variables ¶
This section is empty.
Functions ¶
func ExpandESI ¶
func ExpandESI(resp *http.Response, esiTags []EsiTag, subRequestCallback func(req *http.Request) (*http.Response, error)) (*http.Response, error)
ExpandESI - take http response and replace esi tags
func HTTPResponseFromBytes ¶
HTTPResponseFromBytes - convert bytes to http response
func HTTPResponseToBytes ¶
HTTPResponseToBytes - convert http response to bytes
func PrivateKeyFromRequest ¶
PrivateKeyFromRequest - generate private cache key from request
func PublicKeyFromRequest ¶
PublicKeyFromRequest - generate public cache key from request
func WildcardCompare ¶
WildcardCompare - test if original string matches test string with wildcard
Types ¶
type Config ¶
type Config struct { CacheStorageHandlers []string `json:"cache_storage_handlers"` // list of cache storage handlers to use (in order) CacheFilePath string `json:"cache_file_path"` // file path to file system cache CacheMaxSize map[string]map[string]int `json:"cache_max_size"` // max size for each cache type (public/private) and each cache storage handler ResponseMaxSize int `json:"response_max_size"` // max size allowed to cache a response CleanInterval int `json:"clean_interval"` // interval in seconds of when to performance cache clean up` VaryHeaders []string `json:"vary_headers"` // headers that should be used to calculate cache keys InvalidateHeaders []string `json:"invalidate_headers"` // list of headers to use for cache ban/purge requests CachePrivate bool `json:"enable_private_cache"` // whether or not to cache private content (cache-control: private) VaryCookies []string `json:"vary_cookies"` // list of cookies to use to vary private cache UseESI bool `json:"enable_esi"` // whether or not to handle ESI tags }
Config - cache configuration
type EsiTag ¶
type EsiTag struct { URL string // url for ESI request Position int // position in original response of ESI tag }
EsiTag - data about ESI tag
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage - file system storage handler
func (*FileStorage) FetchResponse ¶
func (s *FileStorage) FetchResponse() (*http.Response, error)
FetchResponse - fetch response from file system
func (*FileStorage) GetSize ¶
func (s *FileStorage) GetSize() (int64, error)
GetSize - get file size of cache item
func (*FileStorage) GetTypeName ¶
func (s *FileStorage) GetTypeName() string
GetTypeName - get storage handler name
func (*FileStorage) Init ¶
func (s *FileStorage) Init(key string, config *Config)
Init - init storage handler
func (*FileStorage) StoreResponse ¶
func (s *FileStorage) StoreResponse(r *http.Response) error
StoreResponse - store http response to file system
type Handler ¶
Handler - main cache handler
func NewHandler ¶
func NewHandler(config Config, subRequestCallback func(req *http.Request) (*http.Response, error)) Handler
NewHandler - create new cache handler
func (*Handler) Invalidate ¶
Invalidate - remove matching items from cache
func (*Handler) OnResponse ¶
OnResponse - handle outgoing response
type Item ¶
type Item struct { Type string Key string Hits int Size int64 Created time.Time LastHit time.Time MaxAge int32 Path string InvalidateHeaders map[string][]string EsiTags []EsiTag // contains filtered or unexported fields }
Item - cached item
func ItemFromResponse ¶
ItemFromResponse - create cache item from response
func (*Item) GetResponse ¶
GetResponse - convert cache item in to http response
func (*Item) GetStorageType ¶
GetStorageType - get storage type name
func (*Item) HasExpired ¶
HasExpired - check if this cache item has expired
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage - memory storage handler
func (*MemoryStorage) FetchResponse ¶
func (s *MemoryStorage) FetchResponse() (*http.Response, error)
FetchResponse - fetch response from file system
func (*MemoryStorage) GetSize ¶
func (s *MemoryStorage) GetSize() (int64, error)
GetSize - get file size of cache item
func (*MemoryStorage) GetTypeName ¶
func (s *MemoryStorage) GetTypeName() string
GetTypeName - get storage handler name
func (*MemoryStorage) Init ¶
func (s *MemoryStorage) Init(key string, config *Config)
Init - init storage handler
func (*MemoryStorage) StoreResponse ¶
func (s *MemoryStorage) StoreResponse(r *http.Response) error
StoreResponse - store http response to file system
type Storage ¶
type Storage interface { Init(key string, config *Config) GetTypeName() string StoreResponse(r *http.Response) error FetchResponse() (*http.Response, error) GetSize() (int64, error) Delete() error }
Storage - define storage handler methods
func GetStorageHandler ¶
GetStorageHandler - get a storage handler from its name