modelcache

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package modelcache persists resolved model.Config values to disk so OpenRouter model configs survive a restart without requiring a fresh catalog fetch.

There is deliberately no TTL or background refresh: startup always refetches every configured OpenRouter model (see the settings-models ticket), and a user who wants fresher data restarts jungi. The cache exists purely as a fallback for when a startup fetch fails (offline, rate limited, etc.) and as the store the /model search flow writes through to so a searched-and-selected model is not lost on restart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadInto

func LoadInto()

LoadInto reads the on-disk cache and registers every entry into the model runtime registry via model.Register, so cached OpenRouter configs resolve through model.ForModel immediately at startup.

func Put

func Put(id model.ID, cfg model.Config) error

Put loads the on-disk cache, sets id's entry to cfg with the current time, and writes the cache back out. It is the write-through path used whenever a model.Config is resolved from the network (settings-configured OpenRouter models at startup, or the /model search flow).

func Save

func Save(c Cache) error

Save writes c to the on-disk model cache, overwriting any existing content. The cache directory is created if it does not already exist.

Types

type Cache

type Cache map[model.ID]Entry

Cache is an in-memory, JSON-serialisable map of model identifiers to their cached Entry.

func Load

func Load() Cache

Load reads the on-disk model cache. A missing or corrupt cache file yields an empty Cache rather than an error, since the cache is purely an optimisation — its absence or corruption must never fail startup.

type Entry

type Entry struct {
	Config    model.Config `json:"config"`
	FetchedAt time.Time    `json:"fetched_at"`
}

Entry pairs a cached model.Config with the time it was fetched, recorded for diagnostics only.

Source Files

  • modelcache.go

Jump to

Keyboard shortcuts

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