memoize

package module
v0.0.0-...-258b99d Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 7 Imported by: 0

README

memoize

Package memoize caches return values of functions.

Documentation

Overview

Package memoize caches return values of functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsSha256

func AsSha256(o interface{}) string

AsSha256 hash a function

Types

type Memoizer

type Memoizer struct {

	// Storage exposes the underlying cache of memoized results to manipulate as desired - for example, to Flush().
	Storage *cache.Cache
	// contains filtered or unexported fields
}

Memoizer allows you to memoize function calls. Memoizer is safe for concurrent use by multiple goroutines.

func NewMemoizer

func NewMemoizer(defaultExpiration, cleanupInterval time.Duration) *Memoizer

NewMemoizer creates a new Memoizer with the configured expiry and cleanup policies. If desired, use cache.NoExpiration to cache values forever.

func (*Memoizer) Memoize

func (m *Memoizer) Memoize(fn interface{}) interface{}

Memoize As a special case, variadic functions (func(x, y, ...z)) are allowed.

Jump to

Keyboard shortcuts

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