Documentation
¶
Index ¶
- type Cache
- func (vc *Cache) BaseDir() string
- func (vc *Cache) Delete(name, version, platform string) bool
- func (vc *Cache) Latest(name, platform string) (version string, ok bool)
- func (vc *Cache) Pin(name, version, platform string) (path string, release func(), ok bool)
- func (vc *Cache) Set(name, version, platform string, data []byte) error
- func (vc *Cache) SetPin(name, version, platform string, data []byte) (string, func(), error)
- func (vc *Cache) Versions(name, platform string) []string
- func (vc *Cache) WarmUp() error
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 wraps a diskcache.Cache with a semver version index. It maintains a sorted (descending) list of versions per name+platform, kept in sync automatically via the diskcache OnEviction callback.
func New ¶
New creates a Cache backed by a bounded diskcache. The OnEviction callback is wired internally to keep the version index consistent when the diskcache evicts entries.
func (*Cache) Delete ¶
Delete explicitly removes an entry from the diskcache. The version index is updated via the OnEviction callback.
func (*Cache) Latest ¶
Latest returns the highest cached semver version for a name+platform. Returns ok=false if nothing is indexed.
func (*Cache) Pin ¶
Pin marks a cache entry as in-use and returns its on-disk path. The entry cannot be evicted until the returned release function is called. The entry file can however be updated while holding the pin, in which case the path will point to the updated content. Returns ok=false if the entry is not in the cache.
func (*Cache) SetPin ¶
SetPin writes data, pins the entry atomically, and updates the version index. The entry cannot be evicted until the returned release function is called.
func (*Cache) Versions ¶
Versions returns all indexed versions for a name+platform, sorted descending. The returned slice is a copy.
func (*Cache) WarmUp ¶
WarmUp scans the cache directory for existing plugin binaries and populates both the diskcache LRU and the version index without reading file contents. Files are adopted into the LRU without triggering eviction — the cache may temporarily exceed maxSize. Eviction occurs naturally on the next Set call.