cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache provides TTL-based on-disk JSON caching for remote API responses. Cache files are stored under ~/.cache/devcell/ (or $XDG_CACHE_HOME/devcell/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir returns the devcell cache directory. Respects $XDG_CACHE_HOME; falls back to ~/.cache/devcell.

func Has

func Has(key string, ttl time.Duration) bool

Has returns true if a valid, non-expired cache entry exists for key. Useful for logging "cached vs network" before calling a fetch function.

func Load

func Load[T any](key string, ttl time.Duration) (T, bool)

Load reads a cached value from disk. Returns (value, true) on a valid, non-expired cache hit; (zero, false) on a miss, parse error, or expiry.

func Save

func Save[T any](key string, value T)

Save writes a value to the cache. Silently ignores write errors so a read-only filesystem never breaks the calling command.

Types

This section is empty.

Jump to

Keyboard shortcuts

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