cache

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides caching for parsed Buildfiles.

The cache stores parsed AST keyed by absolute file path. Cache entries are invalidated when the file's modification time changes. This avoids re-parsing unchanged Buildfiles on subsequent builds.

Cache invalidation strategy:

  • Store file mtime with each entry
  • On lookup, compare current mtime with stored mtime
  • If different, invalidate and return cache miss

The cache is not persistent across process invocations. A future version may add disk-based persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutodepsCache

type AutodepsCache struct {
	// contains filtered or unexported fields
}

AutodepsCache caches parsed .d file contents keyed by absolute path. Cache entries are invalidated when the file's mtime changes.

func NewAutodepsCache

func NewAutodepsCache() *AutodepsCache

NewAutodepsCache creates an empty autodeps cache.

func (*AutodepsCache) Clear

func (c *AutodepsCache) Clear()

Clear removes all entries from the cache.

func (*AutodepsCache) Get

func (c *AutodepsCache) Get(path string) ([]string, bool, error)

Get retrieves cached dependencies for a file. Returns (nil, false, nil) on cache miss. Returns (nil, false, nil) if file has been modified since caching. Returns (nil, false, nil) if file no longer exists. Returns (deps, true, nil) on cache hit.

func (*AutodepsCache) Invalidate

func (c *AutodepsCache) Invalidate(path string)

Invalidate removes a specific entry from the cache.

func (*AutodepsCache) Put

func (c *AutodepsCache) Put(path string, deps []string) error

Put stores parsed dependencies for a file in the cache. The file's current modification time is recorded for invalidation. Returns an error if the file cannot be stat'd.

func (*AutodepsCache) Size

func (c *AutodepsCache) Size() int

Size returns the number of entries in the cache.

type BuildfileCache

type BuildfileCache struct {
	// contains filtered or unexported fields
}

BuildfileCache caches parsed Buildfile ASTs keyed by absolute path. Cache entries are invalidated when the file's mtime changes.

func NewBuildfileCache

func NewBuildfileCache() *BuildfileCache

NewBuildfileCache creates an empty cache.

func (*BuildfileCache) Clear

func (c *BuildfileCache) Clear()

Clear removes all entries from the cache.

func (*BuildfileCache) Get

func (c *BuildfileCache) Get(path string) ([]ast.Statement, bool, error)

Get retrieves cached statements for a file. Returns (nil, false, nil) on cache miss. Returns (nil, false, nil) if file has been modified since caching. Returns (nil, false, nil) if file no longer exists. Returns (statements, true, nil) on cache hit.

func (*BuildfileCache) Invalidate

func (c *BuildfileCache) Invalidate(path string)

Invalidate removes a specific entry from the cache.

func (*BuildfileCache) Put

func (c *BuildfileCache) Put(path string, statements []ast.Statement) error

Put stores parsed statements for a file in the cache. The file's current modification time is recorded for invalidation. Returns an error if the file cannot be stat'd.

func (*BuildfileCache) Size

func (c *BuildfileCache) Size() int

Size returns the number of entries in the cache.

Jump to

Keyboard shortcuts

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