Documentation ¶ Index ¶ type CacheItem type JsonFileCache func (*JsonFileCache[T, TFilter]) Get(filter TFilter, filePath string, maxAge time.Duration) (*T, error) func (*JsonFileCache[T, TFilter]) Save(filter TFilter, filePath string, data *T, maxAge time.Duration) error 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]) 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. Source Files ¶ View all Source files json-file-cache.go Click to show internal directories. Click to hide internal directories.