cache

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBytes

func HashBytes(data []byte) string

HashBytes computes a BLAKE3 hash of bytes.

func HashFile

func HashFile(path string) (string, error)

HashFile computes a BLAKE3 hash of a file's contents.

Types

type Cache

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

Cache provides file-based caching for analysis results.

func New

func New(dir string, ttlHours int, enabled bool) (*Cache, error)

New creates a new cache instance.

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cache entries.

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, bool)

Get retrieves a cached entry if it exists and is not expired.

func (*Cache) GetStats

func (c *Cache) GetStats() (*Stats, error)

GetStats returns statistics about the cache.

func (*Cache) GetWithHash

func (c *Cache) GetWithHash(key, hash string) ([]byte, bool)

GetWithHash retrieves a cached entry only if the hash matches.

func (*Cache) Invalidate

func (c *Cache) Invalidate(key string) error

Invalidate removes a cache entry.

func (*Cache) Set

func (c *Cache) Set(key string, data []byte) error

Set stores data in the cache.

func (*Cache) SetWithHash

func (c *Cache) SetWithHash(key, hash string, data []byte) error

SetWithHash stores data in the cache with a hash for validation.

type Entry

type Entry struct {
	Hash      string    `json:"hash"`
	Timestamp time.Time `json:"timestamp"`
	Data      []byte    `json:"data"`
}

Entry represents a cached analysis result.

type Stats

type Stats struct {
	Entries   int           `json:"entries"`
	TotalSize int64         `json:"total_size"`
	OldestAge time.Duration `json:"oldest_age"`
	NewestAge time.Duration `json:"newest_age"`
}

Stats returns cache statistics.

Jump to

Keyboard shortcuts

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