Documentation ¶
Index ¶
- Constants
- Variables
- func Debugf(format string, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- 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) 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) Status() int
- func (r *Resource) Via() string
- func (r *Resource) Warnings() ([]string, error)
- 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 ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides a storage mechanism for cached Resources
func NewDiskCache ¶
NewDiskCache returns a disk-backed cache
func NewMemoryCache ¶
func NewMemoryCache() *Cache
NewMemoryCache returns an ephemeral cache in memory
func (*Cache) Invalidate ¶
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) LastModified ¶
func (*Resource) MustValidate ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.