cache

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cache provides domain-scoped file caching under a shared cache directory.

Each domain maps to a subdirectory (e.g., "catwalk" → cache/catwalk/). No TTL — cached data is always valid until manually cleared via Clear() or bypassed with the NoCache option.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is the top-level cache manager rooted at a directory.

func New

func New(writeHome string, noCache bool) *Cache

New creates a cache rooted at writeHome/cache. If noCache is true, Read always returns a miss but Write still persists data.

func (*Cache) Clean

func (c *Cache) Clean() error

Clean removes the entire cache directory.

func (*Cache) Dir

func (c *Cache) Dir() string

Dir returns the root cache directory path.

func (*Cache) Domain

func (c *Cache) Domain(name string) *Domain

Domain returns a sub-cache for a specific purpose (e.g., "catwalk", "models").

type Domain

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

Domain is a scoped sub-cache within a named subdirectory.

func (*Domain) Clear

func (d *Domain) Clear() error

Clear removes all entries in this domain.

func (*Domain) Read

func (d *Domain) Read(key string) ([]byte, bool)

Read returns cached data for the given key. Returns nil and false on cache miss, read error, or when noCache is set.

func (*Domain) Write

func (d *Domain) Write(key string, data []byte) error

Write persists data under the given key. Creates the domain directory if it doesn't exist.

Jump to

Keyboard shortcuts

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