cache

package
v7.20.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 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) Clear

func (cache *Cache) Clear()

func (*Cache) Delete

func (cache *Cache) Delete(key string)

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
	IsValid() bool
}

type GetResult

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

Jump to

Keyboard shortcuts

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