Documentation
¶
Overview ¶
Package cache provides a simple interface for cache implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoop = errors.New("noop cacher")
Functions ¶
func ContextWithNoCache ¶ added in v0.24.0
ContextWithNoCache creates a new context with the no cache key/value added to the parent context.
Types ¶
type Cacher ¶ added in v0.20.0
type Cacher interface {
// Del deletes the given key(s).
Del(context.Context, ...string) error
// Get returns the bytes stored under the given key.
Get(context.Context, string) ([]byte, error)
// Set stores a value under a given key, for as long
// as the given duration.
Set(context.Context, string, interface{}, time.Duration) error
}
Cacher defines the methods of any cache client.
type Noop ¶ added in v0.24.2
type Noop struct {
// contains filtered or unexported fields
}
Noop provides a no-op Cacher, useful for testing or other environments where a real Cacher cannot be used.
type PrefixedCacher ¶ added in v0.24.2
type PrefixedCacher struct {
// contains filtered or unexported fields
}
PrefixedCacher wraps a Cacher, and prefixes all cache keys.
func NewPrefixedCacher ¶ added in v0.24.2
func NewPrefixedCacher(c Cacher, keyPrefix string) *PrefixedCacher
NewPrefixedCacher returns a new PrefixedCacher instance.
func (*PrefixedCacher) Del ¶ added in v0.24.2
func (p *PrefixedCacher) Del(ctx context.Context, keys ...string) error