cache

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheItem

type CacheItem[T any, TFilter any] struct {
	// The data that is cached
	Data T `json:"data"`
	// The time when the data was cached
	CachedAt time.Time `json:"cached_at"`

	// Filter criteria, if any
	Filter TFilter `json:"filter,omitempty"`
}

type JsonFileCache

type JsonFileCache[T any, TFilter comparable] struct {
}

A cache that stores data in a JSON file

func (*JsonFileCache[T, TFilter]) Delete added in v0.8.0

func (*JsonFileCache[T, TFilter]) Delete(filePath string) error

Delete the data from the cache

func (*JsonFileCache[T, TFilter]) Get

func (*JsonFileCache[T, TFilter]) Get(filter TFilter, filePath string, maxAge time.Duration) (*T, error)

Get the data from the cache

func (*JsonFileCache[T, TFilter]) Save

func (*JsonFileCache[T, TFilter]) Save(filter TFilter, filePath string, data *T, maxAge time.Duration) error

Save the data to the cache file. The cache file contains a list of CacheItem where the key is the filter.

Jump to

Keyboard shortcuts

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