Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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