loader

package
v0.0.0-...-42c897b Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitHelper

func InitHelper[T msgp.Decodable](ctx context.Context, version string, name string, target *[]T, onInit func(count int64), assetCache AssetCache, hooks ...func(obj T)) error

func LoadRaw

func LoadRaw[T msgp.Decodable](ctx context.Context, version string, name string, onInit func(count int64), assetCache AssetCache, hooks ...func(obj T)) ([]T, error)

LoadRaw loads a raw brotli-compressed json dump from remote source

Returns data from cache if found

func LoadTranslation

func LoadTranslation(ctx context.Context, version string, language string, name string, assetCache AssetCache) (*raw.TranslationFile, error)

LoadTranslation loads a raw brotli-compressed json dump from remote source

Returns data from cache if found

Types

type AssetCache

type AssetCache interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte) error
	Exists(key string) bool
}

func DiskCache

func DiskCache(basePath string, cacheTime time.Duration) (AssetCache, error)

type CalculateFunc

type CalculateFunc[Key comparable, Value any] func(key Key) Value

type ComputationCache

type ComputationCache[Key comparable, Value any] struct {
	Calculate CalculateFunc[Key, Value]
	Data      map[Key]Value
}

func NewComputationCache

func NewComputationCache[Key comparable, Value any](f CalculateFunc[Key, Value]) *ComputationCache[Key, Value]

func (*ComputationCache[Key, Value]) Get

func (c *ComputationCache[Key, Value]) Get(key Key) Value

Jump to

Keyboard shortcuts

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