Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
IsCachableContentType(contentType string) bool
Lookup(key string) (*ContentObject, bool, error)
Store(key string, co *ContentObject) error
Purge(key string) error
}
Cache interface
type ContentObject ¶
type ContentObject struct {
ContentType string
// contains filtered or unexported fields
}
ContentObject represents a cached object
func NewContentObject ¶
func NewContentObject(data []byte, contentType string, headers map[string]string, ttl int, cachedTimestamp int64) *ContentObject
NewContentObject returns a new cache entry
func (*ContentObject) CachedTimestamp ¶
func (co *ContentObject) CachedTimestamp() int64
CachedTimestamp returns the timestamp of the time the object was cached
func (*ContentObject) Content ¶
func (co *ContentObject) Content() []byte
Content exposes the content bytes
func (*ContentObject) Headers ¶
func (co *ContentObject) Headers() map[string]string
Headers returns the headers
type MemcachedCache ¶
type MemcachedCache struct {
// contains filtered or unexported fields
}
MemcachedCache represents a cache object
func NewMemcachedCache ¶
func NewMemcachedCache(options map[string]string) (*MemcachedCache, error)
NewMemcachedCache initialises a new cache
func (*MemcachedCache) IsCachableContentType ¶
func (c *MemcachedCache) IsCachableContentType(contentType string) bool
IsCachableContentType returns true in case the content type is one that can be cached
func (*MemcachedCache) Lookup ¶
func (c *MemcachedCache) Lookup(key string) (*ContentObject, bool, error)
Lookup returns the content if present and a boolean to represent if it's been found In memcache we store the content type in the value in the form: value ="content-type|bytes" so we split on "|"
func (*MemcachedCache) Purge ¶
func (c *MemcachedCache) Purge(key string) error
Purge deletes an item from the cache
func (*MemcachedCache) Store ¶
func (c *MemcachedCache) Store(key string, co *ContentObject) error
Store inserts a new entry into the cache
type MemcachedItem ¶
type MemcachedItem struct {
Content []byte
Headers map[string]string
ContentType string
CachedTimestamp int64
}
MemcachedItem is the structure used to serialize data into memcache
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache represents a cache object
func NewMemoryCache ¶
func NewMemoryCache(options map[string]string) (*MemoryCache, error)
NewMemoryCache initialises a new cache
func (*MemoryCache) IsCachableContentType ¶
func (c *MemoryCache) IsCachableContentType(contentType string) bool
IsCachableContentType returns true in case the content type is one that can be cached
func (*MemoryCache) Lookup ¶
func (c *MemoryCache) Lookup(key string) (*ContentObject, bool, error)
Lookup returns the content if present and a boolean to represent if it's been found
func (*MemoryCache) Purge ¶
func (c *MemoryCache) Purge(key string) error
Purge deletes an item from the cache
func (*MemoryCache) Store ¶
func (c *MemoryCache) Store(key string, co *ContentObject) error
Store inserts a new entry into the cache
type MemoryCacheConfig ¶
type MemoryCacheConfig struct {
MemoryLimit int `yaml:"memory_limit"` // optional, how much memory in bytes to use
TTL int `yaml:"ttl"` // optional, how long each entry is cached for
Patterns []string `yaml:"patterns"` // optional, content-type patterns
ForcePurge bool `yaml:"force_purge"` // optional, delete random items if memory can't be freed up
}
MemoryCacheConfig is how the configuration for the memory cache is represented in the config file
type MemoryItem ¶
type MemoryItem struct {
// contains filtered or unexported fields
}
MemoryItem is the structure used for the in-memory cache
func (*MemoryItem) Expiration ¶
func (co *MemoryItem) Expiration() time.Time
Expiration returns the expiration time for an entry