refreshcache

package
v0.0.0-...-af5906d Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OldValKey = oldVal{}

Functions

This section is empty.

Types

type ClearFunc

type ClearFunc[T any, A any] func(ctx context.Context, args ...A) error

type RefreshCache

type RefreshCache[T any, A any] struct {
	*RefreshData[T, A]
	RefreshFunc atomic.Pointer[RefreshFunc[T, A]]
	ClearFunc   atomic.Pointer[ClearFunc[T, A]]
}

func NewRefreshCache

func NewRefreshCache[T any, A any](refreshFunc RefreshFunc[T, A], maxAge time.Duration, opts ...RefreshDataOption[T, A]) *RefreshCache[T, A]

func (*RefreshCache[T, A]) Clear

func (r *RefreshCache[T, A]) Clear(ctx context.Context, args ...A) error

func (*RefreshCache[T, A]) Data

func (r *RefreshCache[T, A]) Data() *RefreshData[T, A]

func (*RefreshCache[T, A]) Get

func (r *RefreshCache[T, A]) Get(ctx context.Context, args ...A) (data T, err error)

func (*RefreshCache[T, A]) GetRefreshFunc

func (r *RefreshCache[T, A]) GetRefreshFunc() RefreshFunc[T, A]

func (*RefreshCache[T, A]) Refresh

func (r *RefreshCache[T, A]) Refresh(ctx context.Context, args ...A) (data T, err error)

func (*RefreshCache[T, A]) SetClearFunc

func (r *RefreshCache[T, A]) SetClearFunc(clearFunc ClearFunc[T, A])

func (*RefreshCache[T, A]) SetRefreshFunc

func (r *RefreshCache[T, A]) SetRefreshFunc(refreshFunc RefreshFunc[T, A])

type RefreshData

type RefreshData[T any, A any] struct {
	// contains filtered or unexported fields
}

func NewRefreshData

func NewRefreshData[T any, A any](maxAge time.Duration, opts ...RefreshDataOption[T, A]) *RefreshData[T, A]

func (*RefreshData[T, A]) Clear

func (r *RefreshData[T, A]) Clear(ctx context.Context, clearFunc ClearFunc[T, A], args ...A) error

func (*RefreshData[T, A]) Get

func (r *RefreshData[T, A]) Get(ctx context.Context, refreshFunc RefreshFunc[T, A], args ...A) (data T, err error)

func (*RefreshData[T, A]) Last

func (r *RefreshData[T, A]) Last() int64

func (*RefreshData[T, A]) LastErr

func (r *RefreshData[T, A]) LastErr() int64

func (*RefreshData[T, A]) LastErrTime

func (r *RefreshData[T, A]) LastErrTime() time.Time

func (*RefreshData[T, A]) LastTime

func (r *RefreshData[T, A]) LastTime() time.Time

func (*RefreshData[T, A]) MaxAge

func (r *RefreshData[T, A]) MaxAge() int64

func (*RefreshData[T, A]) MaxErrAge

func (r *RefreshData[T, A]) MaxErrAge() int64

func (*RefreshData[T, A]) Raw

func (r *RefreshData[T, A]) Raw() (data T, err error)

func (*RefreshData[T, A]) Refresh

func (r *RefreshData[T, A]) Refresh(ctx context.Context, refreshFunc RefreshFunc[T, A], args ...A) (data T, err error)

type RefreshDataOption

type RefreshDataOption[T any, A any] func(*RefreshData[T, A])

func WithErrAge

func WithErrAge[T any, A any](age time.Duration) RefreshDataOption[T, A]

type RefreshFunc

type RefreshFunc[T any, A any] func(ctx context.Context, args ...A) (T, error)

Jump to

Keyboard shortcuts

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