zstore

package
v0.0.0-...-56f1ebb Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCacheLoader = CacheLoader{
	Marshal:   json.Marshal,
	Unmarshal: json.Unmarshal,
}

Functions

func WithCache

func WithCache(ctx context.Context, key string, fn LoadFn, cache Store, dst interface{}) (err error)

Types

type CacheLoader

type CacheLoader struct {
	Marshal   func(interface{}) ([]byte, error)
	Unmarshal func([]byte, interface{}) error
	// contains filtered or unexported fields
}

func (*CacheLoader) Load

func (l *CacheLoader) Load(ctx context.Context, key string, fn LoadFn, cache Store, dst interface{}) (err error)

type LoadFn

type LoadFn = func() (v interface{}, exp time.Duration, err error)

type Store

type Store interface {
	Get(ctx context.Context, key string) (value []byte, err error)
	Set(ctx context.Context, key string, value []byte, exp time.Duration) (err error)
	Del(ctx context.Context, key string) (err error)
}

Jump to

Keyboard shortcuts

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