localcache

package
v3.8.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyValue

func AnyValue[V any](v any, err error) (V, error)

func GetPublishKeysByTopic added in v3.8.0

func GetPublishKeysByTopic(topics []string, keys []string) map[string][]string

func InitLocalCache added in v3.8.0

func InitLocalCache(localCache *config.LocalCache)

func LRUStringHash added in v3.8.0

func LRUStringHash(key string) uint64

Types

type Cache

type Cache[V any] interface {
	Get(ctx context.Context, key string, fetch func(ctx context.Context) (V, error)) (V, error)
	GetLink(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), link ...string) (V, error)
	Del(ctx context.Context, key ...string)
	DelLocal(ctx context.Context, key ...string)
	Stop()
}

func New

func New[V any](opts ...Option) Cache[V]

type EmptyTarget added in v3.8.0

type EmptyTarget struct{}

func (EmptyTarget) IncrDelHit added in v3.8.0

func (e EmptyTarget) IncrDelHit()

func (EmptyTarget) IncrDelNotFound added in v3.8.0

func (e EmptyTarget) IncrDelNotFound()

func (EmptyTarget) IncrGetFailed added in v3.8.0

func (e EmptyTarget) IncrGetFailed()

func (EmptyTarget) IncrGetHit added in v3.8.0

func (e EmptyTarget) IncrGetHit()

func (EmptyTarget) IncrGetSuccess added in v3.8.0

func (e EmptyTarget) IncrGetSuccess()

type Option

type Option func(o *option)

func WithDeleteKeyBefore

func WithDeleteKeyBefore(fn func(ctx context.Context, key ...string)) Option

func WithExpirationEvict

func WithExpirationEvict() Option

func WithLazy

func WithLazy() Option

func WithLinkDisable

func WithLinkDisable() Option

func WithLinkSlotNum

func WithLinkSlotNum(linkSlotNum int) Option

func WithLocalDisable

func WithLocalDisable() Option

func WithLocalFailedTTL

func WithLocalFailedTTL(localFailedTTL time.Duration) Option

func WithLocalSlotNum

func WithLocalSlotNum(localSlotNum int) Option

func WithLocalSlotSize

func WithLocalSlotSize(localSlotSize int) Option

func WithLocalSuccessTTL

func WithLocalSuccessTTL(localSuccessTTL time.Duration) Option

func WithTarget

func WithTarget(target lru.Target) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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