cache

package
v0.0.66 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store[T interface{}] struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore[T interface{}](ctx context.Context, opts ...StoreOption[T]) *Store[T]

func (*Store[T]) Delete

func (s *Store[T]) Delete(key string)

func (*Store[T]) Flush

func (s *Store[T]) Flush()

func (*Store[T]) GetOrSet

func (s *Store[T]) GetOrSet(key string, getValue func() (T, error)) (T, error)

GetOrSet gets cache value T, or set the value T that returns getValue. If getValue does not return err, cache the value T.

func (*Store[T]) GetOrSetWithTTL

func (s *Store[T]) GetOrSetWithTTL(key string, getValue func() (T, error), ttl time.Duration) (T, error)

GetOrSet gets cache value T, or set the value T that returns getValue with TTL. If getValue does not return err, cache the value T.

func (*Store[T]) ResetRefresher

func (s *Store[T]) ResetRefresher(interval time.Duration)

func (*Store[T]) StopRefresher

func (s *Store[T]) StopRefresher()

type StoreOption

type StoreOption[T interface{}] func(*Store[T])

func WithDefaultTTL

func WithDefaultTTL[T interface{}](ttl time.Duration) StoreOption[T]

func WithRefreshInterval

func WithRefreshInterval[T interface{}](interval time.Duration) StoreOption[T]

Jump to

Keyboard shortcuts

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