Documentation
¶
Index ¶
- func BigCache(ctx context.Context, config bigcache.Config) (*bigcache.BigCache, error)
- func SetClock(newClock clock.Clock) (oldClock clock.Clock)
- func ToInt(v Value) int
- func ToInt64(v Value) int64
- func ToStr(v Value) string
- type BatchLoaderFunc
- type BigCacheOption
- type Cache
- type Factory
- type LoaderFunc
- type LoadingCache
- type LoadingCacheOption
- type PostLoad
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchLoaderFunc ¶
BatchLoaderFunc 加载多个 key 对应的 value,返回值字典里的 value **必须** 是指针类型
type BigCacheOption ¶
func WithMetrics ¶
func WithMetrics(logger *zerolog.Logger, name string) BigCacheOption
type Cache ¶
type Cache interface {
GetWithInfo(key string) (data []byte, expired bool, err error)
Set(key string, value []byte) error
Close() error
Delete(keys ...string) error
}
func NewBigCache ¶
type LoaderFunc ¶
LoaderFunc 加载 key 对应的 value,value **必须** 是指针类型
type LoadingCache ¶
type LoadingCache interface {
Get(ctx context.Context, key string) (Value, error)
BatchGet(ctx context.Context, keys []string) (map[string]Value, error)
Load(ctx context.Context, key string) (Value, error)
BatchLoad(ctx context.Context, keys []string) (map[string]Value, error)
Set(ctx context.Context, key string, value Value) error
SetByData(ctx context.Context, key string, data []byte) error
Delete(ctx context.Context, keys ...string) error
Close(ctx context.Context) error
}
func NewLoading ¶
func NewLoading(cache Cache, factory Factory, load LoaderFunc, opts ...LoadingCacheOption) LoadingCache
func NewNoOp ¶
func NewNoOp(load LoaderFunc) LoadingCache
type LoadingCacheOption ¶
type LoadingCacheOption func(*loadingCache)
func WithBatchLoader ¶
func WithBatchLoader(batchLoad BatchLoaderFunc) LoadingCacheOption
func WithMarshalUnmarshal ¶
func WithMarshalUnmarshal(marshal marshalFunc, unmarshal unmarshalFunc) LoadingCacheOption
func WithPostLoad ¶
func WithPostLoad(postLoad PostLoad) LoadingCacheOption
Click to show internal directories.
Click to hide internal directories.