cache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Janitor = newStatesJanitor()

Functions

This section is empty.

Types

type CacheEntry added in v0.6.0

type CacheEntry[T any] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type CachedContextFunc

type CachedContextFunc[T any] func(ctx context.Context) (T, error)

type CachedContextKeyFunc added in v0.6.0

type CachedContextKeyFunc[T any, K comparable] func(ctx context.Context, key K) (T, error)

type CachedContextKeyFuncState added in v0.6.0

type CachedContextKeyFuncState[T any, K comparable] struct {
	CachedKeyFuncBuilder[T, K]
	// contains filtered or unexported fields
}

func (*CachedContextKeyFuncState[T, K]) Cleanup added in v0.6.0

func (state *CachedContextKeyFuncState[T, K]) Cleanup()

type CachedFuncBuilder

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

func NewFunc

func NewFunc[T any](fn CachedContextFunc[T]) CachedFuncBuilder[T]

NewFunc creates a new CachedFuncBuilder with the given CachedContextFunc).

func (CachedFuncBuilder[T]) Build

func (builder CachedFuncBuilder[T]) Build() CachedContextFunc[T]

func (CachedFuncBuilder[T]) WithRetriesConstantBackoff

func (builder CachedFuncBuilder[T]) WithRetriesConstantBackoff(retries int, interval time.Duration) CachedFuncBuilder[T]

func (CachedFuncBuilder[T]) WithRetriesExponentialBackoff

func (builder CachedFuncBuilder[T]) WithRetriesExponentialBackoff(retries int) CachedFuncBuilder[T]

func (CachedFuncBuilder[T]) WithRetriesZeroBackoff

func (builder CachedFuncBuilder[T]) WithRetriesZeroBackoff(retries int) CachedFuncBuilder[T]

func (CachedFuncBuilder[T]) WithTTL

func (builder CachedFuncBuilder[T]) WithTTL(ttl time.Duration) CachedFuncBuilder[T]

type CachedFuncConfig added in v0.6.0

type CachedFuncConfig struct {
	// contains filtered or unexported fields
}

type CachedFuncState

type CachedFuncState[T any] struct {
	CachedFuncBuilder[T]
	sync.Mutex
	// contains filtered or unexported fields
}

type CachedKeyFuncBuilder added in v0.6.0

type CachedKeyFuncBuilder[T any, K comparable] struct {
	CachedFuncConfig
	// contains filtered or unexported fields
}

func NewKeyFunc added in v0.6.0

func NewKeyFunc[T any, K comparable](fn CachedContextKeyFunc[T, K]) CachedKeyFuncBuilder[T, K]

NewKeyFunc creates a new CachedKeyFuncBuilder with the given CachedContextKeyFunc and default options (15 seconds cleanup interval).

func (CachedKeyFuncBuilder[T, K]) Build added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) Build() CachedContextKeyFunc[T, K]

func (CachedKeyFuncBuilder[T, K]) WithCleanupInterval added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) WithCleanupInterval(cleanupInterval time.Duration) CachedKeyFuncBuilder[T, K]

WithCleanupInterval configures new CachedKeyFuncBuilder instance with the given cleanupInterval. MaxEntries must be set for this to have any effect.

func (CachedKeyFuncBuilder[T, K]) WithMaxEntries added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) WithMaxEntries(maxEntries int) CachedKeyFuncBuilder[T, K]

WithMaxEntries configures new CachedKeyFuncBuilder instance with the given maxEntries.

func (CachedKeyFuncBuilder[T, K]) WithRetriesConstantBackoff added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) WithRetriesConstantBackoff(retries int, interval time.Duration) CachedKeyFuncBuilder[T, K]

func (CachedKeyFuncBuilder[T, K]) WithRetriesExponentialBackoff added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) WithRetriesExponentialBackoff(retries int) CachedKeyFuncBuilder[T, K]

func (CachedKeyFuncBuilder[T, K]) WithRetriesZeroBackoff added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) WithRetriesZeroBackoff(retries int) CachedKeyFuncBuilder[T, K]

func (CachedKeyFuncBuilder[T, K]) WithTTL added in v0.6.0

func (builder CachedKeyFuncBuilder[T, K]) WithTTL(ttl time.Duration) CachedKeyFuncBuilder[T, K]

type State added in v0.6.0

type State interface {
	// Cleanup must be concurrency-safe.
	Cleanup()
}

Jump to

Keyboard shortcuts

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