cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache keeps small name/ID indexes on disk so mistctl can resolve names, fill completions and label IDs without spending API budget.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir() string

DefaultDir returns the cache directory, honouring $MISTCTL_CACHE_DIR.

func IsMAC

func IsMAC(s string) bool

IsMAC reports whether s looks like a MAC address.

func Key

func Key(parts ...string) string

Key builds a cache key from the scope parts (cloud host, org, ...). The token is never part of the key or the stored data.

func NormalizeMAC

func NormalizeMAC(s string) string

NormalizeMAC lowercases a MAC and strips separators.

Types

type Entry

type Entry struct {
	ID     string `json:"id"`
	Name   string `json:"name,omitempty"`
	MAC    string `json:"mac,omitempty"`
	SiteID string `json:"site_id,omitempty"`
	Type   string `json:"type,omitempty"`
}

Entry is one indexed object.

func Match

func Match(entries []Entry, q string) []Entry

Match finds entries whose id, name (case-insensitive) or MAC equals q.

type Store

type Store struct {
	Dir      string
	TTL      time.Duration
	Disabled bool
}

Store is a cache rooted in one directory.

func (*Store) Clear

func (s *Store) Clear() error

Clear removes the cache files mistctl wrote, and only those: scope directories named like a Key, holding index files (and leftover temporary files of interrupted writes). Anything else in the cache directory is left alone, so a cache directory set to a shared folder never loses unrelated files. Obviously unsafe roots (filesystem root, home, current directory) are refused outright.

func (*Store) Get

func (s *Store) Get(scope, kind string) (entries []Entry, fresh bool, ok bool)

Get returns cached entries and whether they are still fresh.

func (*Store) Put

func (s *Store) Put(scope, kind string, entries []Entry) error

Put stores entries.

Jump to

Keyboard shortcuts

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