cache

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K any, O any] struct {
	// contains filtered or unexported fields
}

func New

func New[K any, O any](expiration time.Duration, fetch FetchFunc[K, O]) *Cache[K, O]

func (*Cache[K, O]) Get

func (c *Cache[K, O]) Get(ctx context.Context, key K) (O, error)

func (*Cache[K, O]) Refresh added in v0.11.10

func (c *Cache[K, O]) Refresh(ctx context.Context, key K) (O, error)

Refresh the entry with given key regardless expiration

type FetchAll added in v0.11.8

type FetchAll[K comparable, O any] func(ctx context.Context) (map[K]O, error)

type FetchAllCache added in v0.11.8

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

func NewFetchAll added in v0.11.8

func NewFetchAll[K comparable, O any](expiration time.Duration, fetchAll FetchAll[K, O]) *FetchAllCache[K, O]

func (*FetchAllCache[K, O]) Get added in v0.11.8

func (c *FetchAllCache[K, O]) Get(ctx context.Context, key K) (O, error)

type FetchFunc

type FetchFunc[K any, O any] func(ctx context.Context, key K) (O, error)

Jump to

Keyboard shortcuts

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