memoizer

package
v0.4.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memoizer

type Memoizer[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func New

func New[K comparable, V any](fn func(K) V, opts ...Opt[K, V]) *Memoizer[K, V]

func (*Memoizer[K, V]) Call

func (m *Memoizer[K, V]) Call(k K) V

func (*Memoizer[K, V]) Cleanup

func (m *Memoizer[K, V]) Cleanup()

func (*Memoizer[K, V]) Clear

func (m *Memoizer[K, V]) Clear()

func (*Memoizer[K, V]) Len

func (m *Memoizer[K, V]) Len() int

func (*Memoizer[K, V]) Reset

func (m *Memoizer[K, V]) Reset()

func (*Memoizer[K, V]) Stats

func (m *Memoizer[K, V]) Stats() Stats

type Opt

type Opt[K comparable, V any] func(m *Memoizer[K, V])

func WithCondition

func WithCondition[K comparable, V any](fn func(V) bool) Opt[K, V]

func WithMax

func WithMax[K comparable, V any](value int) Opt[K, V]

type Stats

type Stats struct {
	CacheSize int
	CacheHit  uint
	CacheMiss uint
}

func (*Stats) CacheRatio

func (s *Stats) CacheRatio() float32

Jump to

Keyboard shortcuts

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