Documentation ¶
Index ¶
- Constants
- Variables
- type Cache
- type CacheControl
- type Handler
- type Header
- type Key
- type ReadSeekCloser
- type Resource
- func (r *Resource) Age() (time.Duration, error)
- func (r *Resource) DateAfter(d time.Time) bool
- func (r *Resource) Expires() (time.Time, error)
- func (r *Resource) HasExplicitExpiration() bool
- func (r *Resource) HasValidators() bool
- func (r *Resource) Header() http.Header
- func (r *Resource) HeuristicFreshness() time.Duration
- func (r *Resource) IsNonErrorStatus() bool
- func (r *Resource) IsStale() bool
- func (r *Resource) LastModified() time.Time
- func (r *Resource) MarkStale()
- func (r *Resource) MaxAge(shared bool) (time.Duration, error)
- func (r *Resource) MustValidate(shared bool) bool
- func (r *Resource) RemovePrivateHeaders()
- func (r *Resource) Status() int
- func (r *Resource) Via() string
- type Validator
Constants ¶
View Source
const ( CacheHeader = "X-Cache" ProxyDateHeader = "Proxy-Date" )
View Source
const (
CacheControlHeader = "Cache-Control"
)
Variables ¶
View Source
var Clock = func() time.Time { return time.Now().UTC() }
View Source
var DebugLogging = false
View Source
var ErrNotFoundInCache = errors.New("Not found in cache")
Returned when a resource doesn't exist
View Source
var Writes sync.WaitGroup
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Header(key string) (Header, error) Store(res *Resource, keys ...string) error Retrieve(key string) (*Resource, error) Invalidate(keys ...string) Freshen(res *Resource, keys ...string) error }
func NewDiskCache ¶
NewDiskCache returns a disk-backed cache
func NewMemoryCache ¶
func NewMemoryCache() Cache
NewMemoryCache returns an ephemeral cache in memory
func NewVFSCache ¶ added in v1.2.0
NewCache returns a cache backend off the provided VFS
type CacheControl ¶
func ParseCacheControl ¶
func ParseCacheControl(input string) (CacheControl, error)
func ParseCacheControlHeaders ¶
func ParseCacheControlHeaders(h http.Header) (CacheControl, error)
func (CacheControl) Add ¶
func (cc CacheControl) Add(key, val string)
func (CacheControl) Has ¶
func (cc CacheControl) Has(key string) bool
func (CacheControl) String ¶
func (cc CacheControl) String() string
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents a unique identifier for a resource in the cache
func NewRequestKey ¶
RequestKey generates a Key for a request
type Resource ¶
type Resource struct { ReadSeekCloser RequestTime, ResponseTime time.Time // contains filtered or unexported fields }
func NewResource ¶
func NewResource(statusCode int, body ReadSeekCloser, hdrs http.Header) *Resource
func (*Resource) HasExplicitExpiration ¶
func (*Resource) HasValidators ¶
func (*Resource) HeuristicFreshness ¶
func (*Resource) IsNonErrorStatus ¶ added in v1.2.0
func (*Resource) LastModified ¶
func (*Resource) MustValidate ¶
func (*Resource) RemovePrivateHeaders ¶ added in v1.2.0
func (r *Resource) RemovePrivateHeaders()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.