wavecache

package
v0.85.0-pre.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package wavecache provides low-level runtime cache primitives shared by Wave runtime services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyedCache

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

KeyedCache caches keyed values in production mode, while recomputing on each key access in development mode.

func NewKeyedCache

func NewKeyedCache[K comparable, V any](
	fn func(K) (V, error),
) *KeyedCache[K, V]

NewKeyedCache creates a KeyedCache with default successful-result caching.

func NewKeyedCacheWithPolicyAndModeResolver

func NewKeyedCacheWithPolicyAndModeResolver[K comparable, V any](
	fn func(K) (V, error),
	shouldCache func(V, error) bool,
	isDevMode func() bool,
) *KeyedCache[K, V]

NewKeyedCacheWithPolicyAndModeResolver creates a KeyedCache with custom retention and mode policy.

func (*KeyedCache[K, V]) Get

func (cache *KeyedCache[K, V]) Get(key K) (V, error)

Get resolves and returns one keyed value.

type ValueCache

type ValueCache[T any] struct {
	// contains filtered or unexported fields
}

ValueCache caches one lazily computed value in production mode, while recomputing on every access in development mode.

func NewValueCache

func NewValueCache[T any](fn func() (T, error)) *ValueCache[T]

NewValueCache creates a ValueCache with production-only caching behavior.

func NewValueCacheWithModeResolver

func NewValueCacheWithModeResolver[T any](
	fn func() (T, error),
	isDevMode func() bool,
) *ValueCache[T]

NewValueCacheWithModeResolver creates a ValueCache with one mode resolver.

func (*ValueCache[T]) Get

func (cache *ValueCache[T]) Get() (T, error)

Get resolves and returns the cached value.

Jump to

Keyboard shortcuts

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