Documentation ¶
Overview ¶
Package funcs provides utilities for functions, such as caching and memoization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Memoize ¶
Memoize the result of a function call.
fn is only ever called once, even if it returns an error.
func MemoizeNoError ¶
func MemoizeNoError[T any](fn func() T) func() T
MemoizeNoError the result of a function call.
fn is only ever called once
Types ¶
type CachedFunc ¶
CachedFunc represents a function which caches its result, but can also be flushed.
func Cache ¶
func Cache[T any](fn func() (*T, error)) CachedFunc[T]
Cache the result of a function call, with the ability to flush the cache.
func CacheWithCallback ¶
func CacheWithCallback[T any](fn func() (*T, error), cb func()) CachedFunc[T]
CacheWithCallback the result of a function call, with the ability to flush the cache. The provided callback function will be called when the cache is flushed.
Click to show internal directories.
Click to hide internal directories.