cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cache provides per-file caching for graph extraction results. Cache keys are based on SHA256 hashes of file content, so cached results are automatically invalidated when files change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// Dir is the cache directory (typically .graphize/cache/).
	Dir string
}

Cache manages per-file extraction caches.

func New

func New(graphDir string) *Cache

New creates a new cache instance. graphDir should be the root graph directory (e.g., ".graphize").

func (*Cache) CheckMultiple

func (c *Cache) CheckMultiple(baseDir string, paths []string) (cached, uncached []CheckResult)

CheckMultiple checks multiple files against the cache. Returns separate lists of cached and uncached files.

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cached entries.

func (*Cache) Get

func (c *Cache) Get(path, relPath string) (*CachedExtraction, bool)

Get retrieves a cached extraction for a file path. Returns nil, false if not cached or if the file has changed.

func (*Cache) Hash

func (c *Cache) Hash(path string) (string, error)

Hash computes the SHA256 hash of a file's content.

func (*Cache) Init

func (c *Cache) Init() error

Init ensures the cache directory exists.

func (*Cache) Set

func (c *Cache) Set(path, relPath string, nodes []*graph.Node, edges []*graph.Edge) error

Set stores an extraction result in the cache.

func (*Cache) Size

func (c *Cache) Size() (int, error)

Size returns the number of cached entries.

type CacheStats

type CacheStats struct {
	Hits   int
	Misses int
}

CacheStats tracks cache hit/miss statistics.

type CachedExtraction

type CachedExtraction struct {
	// FileHash is the SHA256 hash of the file content.
	FileHash string `json:"file_hash"`

	// FilePath is the relative path of the source file.
	FilePath string `json:"file_path"`

	// Nodes extracted from this file.
	Nodes []*graph.Node `json:"nodes"`

	// Edges extracted from this file.
	Edges []*graph.Edge `json:"edges"`
}

CachedExtraction stores the extraction results for a single file.

type CheckResult

type CheckResult struct {
	Path    string
	RelPath string
	Cached  bool
	Entry   *CachedExtraction
}

CheckResult contains the result of checking a file against the cache.

Jump to

Keyboard shortcuts

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