Documentation ¶
Overview ¶
Package cache provides an Image cache.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Async ¶
type Async struct {
Cache
}
Async is an asynchronous Cache.
The Images are set from a new goroutine.
func (*Async) Set ¶
func (a *Async) Set(key string, image *imageserver.Image, params imageserver.Params) error
Set implements Cache.
type Cache ¶
type Cache interface { // Must return nil and no error if the image is not found. Get(key string, params imageserver.Params) (*imageserver.Image, error) Set(key string, image *imageserver.Image, params imageserver.Params) error }
Cache represents an Image cache.
The Params can be used for custom behavior (no-cache, expiration, ...).
type Func ¶
type Func struct { GetFunc func(key string, params imageserver.Params) (*imageserver.Image, error) SetFunc func(key string, image *imageserver.Image, params imageserver.Params) error }
Func is an Image Cache that forwards calls to user defined functions
func (*Func) Get ¶
func (c *Func) Get(key string, params imageserver.Params) (*imageserver.Image, error)
Get implements Cache.
func (*Func) Set ¶
func (c *Func) Set(key string, image *imageserver.Image, params imageserver.Params) error
Set implements Cache.
type IgnoreError ¶
type IgnoreError struct {
Cache
}
IgnoreError is a Cache that ignores error from the underlying Cache.
func (*IgnoreError) Get ¶
func (c *IgnoreError) Get(key string, params imageserver.Params) (*imageserver.Image, error)
Get implements Cache.
func (*IgnoreError) Set ¶
func (c *IgnoreError) Set(key string, image *imageserver.Image, params imageserver.Params) error
Set implements Cache.
type KeyGenerator ¶
type KeyGenerator interface {
GetKey(imageserver.Params) string
}
KeyGenerator represents a Cache key generator.
func NewParamsHashKeyGenerator ¶
func NewParamsHashKeyGenerator(newHashFunc func() hash.Hash) KeyGenerator
NewParamsHashKeyGenerator returns a new KeyGenerator that hashes the Params.
type KeyGeneratorFunc ¶
type KeyGeneratorFunc func(imageserver.Params) string
KeyGeneratorFunc is a KeyGenerator func.
func (KeyGeneratorFunc) GetKey ¶
func (f KeyGeneratorFunc) GetKey(params imageserver.Params) string
GetKey implements KeyGenerator.
type PrefixKeyGenerator ¶
type PrefixKeyGenerator struct { KeyGenerator Prefix string }
PrefixKeyGenerator is a KeyGenerator that adds a prefix to the key.
func (*PrefixKeyGenerator) GetKey ¶
func (g *PrefixKeyGenerator) GetKey(params imageserver.Params) string
GetKey implements KeyGenerator.
type Server ¶
type Server struct { imageserver.Server Cache Cache KeyGenerator KeyGenerator }
Server is a Server with Cache.
Steps:
- Generate the cache key.
- Get the Image from the Cache, and return it if found.
- Get the Image from the Server.
- Set the Image to the Cache.
- Return the Image.
func (*Server) Get ¶
func (s *Server) Get(params imageserver.Params) (*imageserver.Image, error)
Get implements Server.
Directories ¶
Path | Synopsis |
---|---|
Package _test provides utilities for Cache testing.
|
Package _test provides utilities for Cache testing. |
Package groupcache provides a groupcache Image Server.
|
Package groupcache provides a groupcache Image Server. |
Package memcache provides a Memcache Image Cache.
|
Package memcache provides a Memcache Image Cache. |
Package memory provides an in-memory Image Cache.
|
Package memory provides an in-memory Image Cache. |
Package redis provides a Redis Image Cache.
|
Package redis provides a Redis Image Cache. |