cache

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cache provides a simple file-based cache implementation that fullfills the RefreshReadWriter interface.

It writes and reads the cache to a file in JSON format, along with the last refresh time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheWrap added in v0.5.0

type CacheWrap struct {
	Data        any       `json:"data"`
	RefreshedAt time.Time `json:"refreshed_at"`
}

type FileCache

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

func NewFileCache

func NewFileCache(path string) *FileCache

func (*FileCache) Read

func (c *FileCache) Read(out any) error

func (*FileCache) Refresh added in v0.5.0

func (c *FileCache) Refresh(t time.Time)

func (*FileCache) RefreshedAt added in v0.4.6

func (c *FileCache) RefreshedAt() time.Time

func (*FileCache) Write

func (c *FileCache) Write(in any) error

type RefreshReadWriter added in v0.5.0

type RefreshReadWriter interface {
	Read(any) error
	Write(any) error
	Refresh(time.Time)
	RefreshedAt() time.Time
}

Jump to

Keyboard shortcuts

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