cache: Index | Files | Directories

package mw

import ""


Package Files

fallback.go gc.go metrics.go

func HandleByErr Uses

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

HandleByErr checks if cache return err.

func LabelName Uses

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

LabelName sets static name.

func LabelPreficKey Uses

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

LabelPreficKey gets lebale by item prefix.

func WithClearByContext Uses

func WithClearByContext(ctxKey interface{}) cache.Configure

WithClearByContext clear cache if context done.

func WithClearByTTL Uses

func WithClearByTTL() cache.Configure

WithClearByTTL clear cache by key after ttl.

func WithFallback Uses

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 Uses

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 Uses

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

WithMetrics cache middleware metrics.

type Fallback Uses

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

func LockFallback Uses

func LockFallback(fallback Fallback) Fallback

LockFallback locks run fallback by item key.

type Getter Uses

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

type Metrics Uses

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.



Package mw imports 6 packages (graph) and is imported by 1 packages. Updated 2021-01-28. Refresh now. Tools for package owners.