lru

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncCacheCall

func FuncCacheCall[T any](ctx context.Context, cache ILRUCache, key string, cacheFunc CacheFunc[T], expireDuration time.Duration) (T, error)

Types

type CacheFunc

type CacheFunc[T any] func(ctx context.Context) (T, error)

type ILRUCache

type ILRUCache interface {
	Set(ctx context.Context, key string, value interface{}, expireAt time.Time)
	Get(ctx context.Context, key string) (interface{}, bool)
}

func NewLRUCache

func NewLRUCache(maxLen int) ILRUCache

type Result

type Result struct {
	ExpireAt time.Time
	Data     unsafe.Pointer
}

type T

type T struct {
	// contains filtered or unexported fields
}

func (*T) Get

func (x *T) Get(ctx context.Context, key string) (interface{}, bool)

func (*T) Set

func (x *T) Set(ctx context.Context, key string, value interface{}, expireAt time.Time)

Jump to

Keyboard shortcuts

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