Documentation ¶
Index ¶
- Constants
- func PanicOnOverweight(k, v any)
- type Cache
- func (c *Cache[K]) Clear()
- func (c *Cache[K]) Contains(k K) bool
- func (c *Cache[K]) Delete(k K) bool
- func (c *Cache[K]) ForEach(fn func(bt.Kv[K, any]) bool) bool
- func (c *Cache[K]) Get(k K) any
- func (c *Cache[K]) Iterate() bt.Iterator[bt.Kv[K, any]]
- func (c *Cache[K]) Len() int
- func (c *Cache[K]) Put(k K, v any) bool
- func (c *Cache[K]) Reap()
- func (c *Cache[K]) TryGet(k K) (any, bool)
- type Config
- type Eviction
- type LFU
- type LRI
- type LRU
- type OverweightError
- type Stats
- type Weight
Constants ¶
View Source
const DefaultMaxSize = 256
Variables ¶
This section is empty.
Functions ¶
func PanicOnOverweight ¶
func PanicOnOverweight(k, v any)
Types ¶
type Cache ¶
type Cache[K comparable] struct { // contains filtered or unexported fields }
func NewCache ¶
func NewCache[K comparable](cfg Config) *Cache[K]
type Config ¶
type Config struct { MaxSize int Weigher func(v any) Weight MaxWeight Weight ExpireAfterAccess time.Duration ExpireAfterWrite time.Duration OnAdd func(k, v any) OnRemove func(k, v any) OnOverweight func(k, v any) Clock func() time.Time Lock sync.Locker Eviction Eviction TrackFrequency bool }
func DefaultConfig ¶
func DefaultConfig() Config
type OverweightError ¶
type OverweightError struct {
Key, Value any
}
func (OverweightError) Error ¶
func (e OverweightError) Error() string
Click to show internal directories.
Click to hide internal directories.