cache

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the PSRT config root (PSRT_CONFIG_DIR or OS default).

func FetchDocumentURLsWithCache

func FetchDocumentURLsWithCache(ctx context.Context, client *http.Client, store *Store, doc psrt.Document, urls []string) (map[string]compileasset.Asset, error)

FetchDocumentURLsWithCache uses page labels from doc for any missing cache entries.

func FetchURLsWithCache

func FetchURLsWithCache(ctx context.Context, client *http.Client, store *Store, urls []string) (map[string]compileasset.Asset, error)

FetchURLsWithCache loads assets from disk when mapped; otherwise downloads and caches.

func LoadMap

func LoadMap(path string) (map[string]string, error)

LoadMap reads URL → relative path entries from assets.map.

func SaveMap

func SaveMap(path, psrtBase string, m map[string]string) error

SaveMap writes assets.map with a header comment.

func URLPageLabels

func URLPageLabels(doc psrt.Document) map[string]string

URLPageLabels builds url → page label for EnsureDocument.

Types

type Store

type Store struct {
	RootDir   string
	MapPath   string
	ImagesDir string
	PsrtBase  string
	PsrtDir   string
	// contains filtered or unexported fields
}

Store manages on-disk cache for one PSRT file's remote assets.

func NewStore

func NewStore(configDir, psrtPath string) (*Store, error)

NewStore creates or opens cache for psrtPath under configDir/cache/{basename}/.

func (*Store) EnsureCached

func (s *Store) EnsureCached(ctx context.Context, client *http.Client, url, pageLabel string) error

EnsureCached downloads or copies url if not cached locally.

func (*Store) EnsureDocument

func (s *Store) EnsureDocument(ctx context.Context, client *http.Client, doc psrt.Document) error

EnsureDocument warms cache for all HTTP URLs in doc.

func (*Store) ReadAsset

func (s *Store) ReadAsset(url string) (compileasset.Asset, bool, error)

ReadAsset loads bytes for url from cache or returns false.

func (*Store) RefreshAsset

func (s *Store) RefreshAsset(ctx context.Context, client *http.Client, url, pageLabel string) error

RefreshAsset forces re-download or re-read from disk and updates the map.

func (*Store) ResolveAbsolute

func (s *Store) ResolveAbsolute(url string) (string, bool)

ResolveAbsolute returns full path for a cached URL if file exists.

Jump to

Keyboard shortcuts

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