cache

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 7 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

Index

Constants

View Source
const (
	// TTL is the time-to-live for cached items.
	TTL = 24 * time.Hour

	// FileLockRetryDelay is the delay between retries when acquiring file locks.
	FileLockRetryDelay = 100 * time.Millisecond
)

Variables

View Source
var ErrNotFound = errors.New("item not found")

ErrNotFound is returned when an item is not found in the cache.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get retrieves an item from the cache.
	Get(ctx context.Context, path string) (*Item, error)

	// Put inserts or updates an item in the cache.
	Put(ctx context.Context, item *Item) error
}

Cache is the interface for caching file related information.

func New

func New(storageDir string) (Cache, error)

New creates a new cache instance.

type Item

type Item struct {
	// Path is the absolute path of the file.
	Path string `json:"path"`

	// ModTime is the last modification time of the file.
	ModTime time.Time `json:"mod_time"`

	// Size is the size of the file in bytes.
	Size int64 `json:"size"`

	// Digest is the SHA-256 digest of the file.
	Digest string `json:"digest"`

	// CreatedAt is the time when the item was created.
	CreatedAt time.Time `json:"created_at"`
}

Item represents a cached file item.

Jump to

Keyboard shortcuts

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