cache

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTTL = 1 * time.Hour

Functions

func Get

func Get[T any](cache Cache, key string, fetcher func() (T, error), options ...CacheConfigFunc) (T, error)

Types

type Cache

type Cache interface {
	Set(key string, value any, ttl time.Duration) error
	Get(key string) (any, error)
	Remove(key ...string) error
	Pop(key string) (any, error)
	Keys(prefix string) []string
}

type CacheConfigFunc

type CacheConfigFunc func(*config)

func AsyncSetter

func AsyncSetter(value bool) CacheConfigFunc

func OnError

func OnError(fn func(err error)) CacheConfigFunc

func TTL

func TTL(duration time.Duration) CacheConfigFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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