cache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache ports estimate/src/cache.ts of the Node estimate (manager): the estimate's cache under ~/.cache/dormeto/estimate/<organization or account>/, byte-compatible with Node's files. A file is {"writtenAt": <ms since the epoch>, "value": ...}, written to a temporary name then renamed (an interrupted run never leaves a broken one); one that cannot be parsed is missing. prices.json is {"<key>": {"usd": number|null, "until": <ms>}}.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(env func(string) string) string

Dir is $XDG_CACHE_HOME/dormeto/estimate, else ~/.cache/dormeto/estimate, on every OS.

func FreshDiscovery

func FreshDiscovery(now time.Time) func(time.Time) bool

FreshDiscovery: discovery is fresh a day.

func FreshRequests

func FreshRequests(now time.Time) func(time.Time) bool

FreshRequests: requests (and uptime) are fresh while their days (--days) end on the run's UTC day.

Types

type Cache

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

Cache is the estimate's file cache.

func New

func New(dir string, now func() time.Time) *Cache

New returns a cache under dir; now is the clock (time.Now when nil).

func (*Cache) Get

func (c *Cache) Get(path string, fresh func(writtenAt time.Time) bool, out any) (bool, error)

Get reads path (relative to the cache directory) into out when the file is parsable, has a writtenAt and a value, and fresh accepts its time. Anything else, a missing or unparsable file included, is (false, nil).

func (*Cache) Prices

func (c *Cache) Prices() prices.Cache

Prices is the price cache kept in prices.json.

func (*Cache) Put

func (c *Cache) Put(path string, value any) error

Put writes value with the time now, atomically.

Jump to

Keyboard shortcuts

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