Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrWalkStop = errors.New("stop walking")
ErrWalkStop is used to stop walking over the cache items.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] interface { Get(ctx context.Context, key string) (*T, bool, error) Set(ctx context.Context, key string, info *T) error Delete(ctx context.Context, key string) error }
Cache is an interface for caching information.
type CacheIterator ¶
type CacheIterator[T any] interface { Cache[T] Walk(ctx context.Context, fn func(key string, value *T) error) error First(ctx context.Context, fn func(value *T) bool) (string, *T, bool, error) }
CacheIterator is an interface for iterating over a cache.
func NewMemoryCache ¶
func NewMemoryCache[T any](maxCount int) CacheIterator[T]
NewMemoryCache creates a new MemoryCache with the specified maximum count. If maxCount is zero or negative, a default value is calculated based on the available memory.
Click to show internal directories.
Click to hide internal directories.