Documentation ¶
Overview ¶
Package safecache provides a generic, thread-safe, lazily initiated cache that ensures initialization occurs only once unless bypass is requested.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache is a generic, thread-safe cache that ensures initialization occurs only once unless bypass is requested.
type CacheMap ¶ added in v0.0.29
type CacheMap[K any, DK comparable, V any] struct { // contains filtered or unexported fields }
CacheMap is a generic, thread-safe cache map that caches values based on derived keys.
func NewMap ¶ added in v0.0.29
func NewMap[K any, DK comparable, V any]( initFunc mapInitFunc[K, V], mapToKeyFunc mapToKeyFunc[K, DK], bypassFunc mapBypassFunc[K], ) *CacheMap[K, DK, V]
NewMap creates a new CacheMap instance. If bypassFunc is provided and returns true, initFunc will run every time. Panics if initFunc or mapToKeyFunc is nil.
Click to show internal directories.
Click to hide internal directories.