Documentation ¶
Index ¶
- Constants
- func DecorateFunction[T any, R any](cache Cache[T, R], fn func(T) (R, error)) func(T) (R, error)
- func DefaultCacheResultPredicate(_ any, _ error) bool
- func DefaultKeyToHash(key any) (uint64, uint64)
- type Cache
- type Config
- type ConfigBuilder
- type Event
- type EventListener
- type EventType
- type HitEvent
- type Metrics
- type MissEvent
Constants ¶
View Source
const DefaultCapacity int64 = 10000
View Source
const DefaultItemTTL = time.Minute * 5
Variables ¶
This section is empty.
Functions ¶
func DecorateFunction ¶
func DefaultCacheResultPredicate ¶ added in v0.5.0
func DefaultKeyToHash ¶
Types ¶
type Cache ¶
type ConfigBuilder ¶
type ConfigBuilder func(*Config)
func WithCacheResultPredicate ¶ added in v0.5.0
func WithCacheResultPredicate(function func(any, error) bool) ConfigBuilder
func WithCapacity ¶
func WithCapacity(capacity int64) ConfigBuilder
func WithItemTTL ¶
func WithItemTTL(itemTTL time.Duration) ConfigBuilder
func WithKeyToHash ¶
func WithKeyToHash(function func(any) (uint64, uint64)) ConfigBuilder
type EventListener ¶
type EventListener interface { OnCacheHitFunc(func(HitEvent)) EventListener OnCacheMissFunc(func(MissEvent)) EventListener DismissCacheHitFunc(func(HitEvent)) EventListener DismissCacheMissFunc(func(MissEvent)) EventListener OnCacheHit(fn.Consumer[HitEvent]) EventListener OnCacheMiss(fn.Consumer[MissEvent]) EventListener DismissCacheHit(fn.Consumer[HitEvent]) EventListener DismissCacheMiss(fn.Consumer[MissEvent]) EventListener }
Click to show internal directories.
Click to hide internal directories.