Documentation
¶
Index ¶
- Constants
- Variables
- type Loader
- func (ld *Loader) Contains(ctx context.Context, key string) bool
- func (ld *Loader) Hits() int64
- func (ld *Loader) Load(ctx context.Context, key string) (interface{}, error)
- func (ld *Loader) Misses() int64
- func (ld *Loader) Ratio() float64
- func (ld *Loader) Remove(ctx context.Context, key string)
- func (ld *Loader) Stats() string
- func (ld *Loader) Update(ctx context.Context, key string, value interface{}) error
- type LoaderFunc
Constants ¶
View Source
const ( // DefaultTTL is the default TTL used if nothing else is specified. // Keep this short by default to support subsequent queries of the same item // and to avoid a stale cache in the long run. DefaultTTL = time.Minute * 2 MsgInvalidTTL = "TTL can not be less than zero" MsgMissingLoaderFunc = "loader function is missing" )
Variables ¶
View Source
var ( ErrInvalidTTL = errors.New(MsgInvalidTTL) ErrMissingLoaderFunc = errors.New(MsgMissingLoaderFunc) )
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader holds cached resources. The cache is a simple in-memory cache with TTL.
func (*Loader) Load ¶
Load returns either a cached resource or calls the loader function to retrieve the requested resource
Click to show internal directories.
Click to hide internal directories.