mw

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleByErr

func HandleByErr(_ *cache.Item, err error) bool

HandleByErr checks if cache return err.

func LabelName

func LabelName(name string) func(ctx context.Context, item *cache.Item) string

LabelName sets static name.

func LabelPreficKey

func LabelPreficKey(ctx context.Context, item *cache.Item) string

LabelPreficKey gets lebale by item prefix.

func WithClearByContext

func WithClearByContext(ctxKey interface{}) cache.Configure

WithClearByContext clear cache if context done.

func WithClearByTTL

func WithClearByTTL() cache.Configure

WithClearByTTL clear cache by key after ttl.

func WithFallback

func WithFallback(fallback Fallback, isHandleFallback func(*cache.Item, error) bool) cache.Configure

WithFallback sets fallback when cache handle success and set result in cache.

func WithLockGetter added in v0.2.0

func WithLockGetter(getter Getter, isHandle func(*cache.Item, error) bool) cache.Configure

WithLockGetter sets values from getter when cache handle success and set result in cache.

func WithMetrics

func WithMetrics(m Metrics, labelCallback func(ctx context.Context, item *cache.Item) string) cache.Configure

WithMetrics cache middleware metrics.

Types

type Fallback added in v0.2.0

type Fallback func(ctx context.Context, key, value interface{}) error

func LockFallback

func LockFallback(fallback Fallback) Fallback

LockFallback locks run fallback by item key.

type Getter added in v0.2.0

type Getter func(ctx context.Context, key interface{}) (interface{}, error)

type Metrics

type Metrics interface {
	Hit(label string)
	Miss(label string)
	Expired(label string)
	Err(label string, operation string)
	Observe(label string, operation string, start time.Time)
}

Metrics interface for middleware.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL