cache

package
v7.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(compactInterval time.Duration) *Cache

func NewPersistentCache

func NewPersistentCache(
	valueType reflect.Type,
	persistentFilePath string,
	compactInterval time.Duration,
	persistentDuration time.Duration,
	handleError func(error),
) (*Cache, error)

func (*Cache) Get

func (cache *Cache) Get(key string, fallback func() (CacheValue, error)) (CacheValue, GetResult)

func (*Cache) Set

func (cache *Cache) Set(key string, value CacheValue)

type CacheValue

type CacheValue interface {
	IsEqual(CacheValue) bool
	ShouldRefresh() bool
	IsValid() bool
}

type GetResult

type GetResult uint8
const (
	GetResultFromCache                GetResult = 0
	GetResultFromCacheAndRefreshAsync GetResult = 1
	GetResultFromFallback             GetResult = 2
	GetResultFromInvalidCache         GetResult = 3
	NoResultGot                       GetResult = 4
)

Jump to

Keyboard shortcuts

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