Documentation
¶
Index ¶
Constants ¶
const ( // ProtocolCacheName is the filename for the cached /api/mcp/schemas response. ProtocolCacheName = "schemas.json" // ProtocolCacheTTL is the TTL for protocol schema cache entries. ProtocolCacheTTL = 1 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
func CacheDir() string
CacheDir returns the directory where kh stores cache files. Defaults to ~/.cache/kh; respects $XDG_CACHE_HOME if set.
func IsStale ¶
func IsStale(entry *CacheEntry, ttl time.Duration) bool
IsStale reports whether the cache entry is older than the given TTL.
func WriteCache ¶
func WriteCache(name string, data json.RawMessage) error
WriteCache serializes data into a CacheEntry with the current UTC time and writes it to the cache directory. The cache directory is created if needed.
Types ¶
type CacheEntry ¶
type CacheEntry struct {
FetchedAt time.Time `json:"fetchedAt"`
Data json.RawMessage `json:"data"`
}
CacheEntry wraps cached data with a fetch timestamp.
func ReadCache ¶
func ReadCache(name string) (*CacheEntry, error)
ReadCache reads and unmarshals the named cache file from the cache directory. Returns an error if the file does not exist or cannot be parsed.