cache

package standard library
go1.22.8 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Overview

Package cache implements a build artifact cache.

Index

Constants

View Source
const HashSize = 32

HashSize is the number of bytes in a hash.

Variables

View Source
var DebugTest = false

DebugTest is set when GODEBUG=gocachetest=1 is in the environment.

Functions

func DefaultDir

func DefaultDir() string

DefaultDir returns the effective GOCACHE setting. It returns "off" if the cache is disabled.

func FileHash

func FileHash(file string) ([HashSize]byte, error)

FileHash returns the hash of the named file. It caches repeated lookups for a given file, and the cache entry for a file can be initialized using SetFileHash. The hash used by FileHash is not the same as the hash used by NewHash.

func PutBytes added in go1.21.0

func PutBytes(c Cache, id ActionID, data []byte) error

PutBytes stores the given bytes in the cache as the output for the action ID.

func SetFileHash

func SetFileHash(file string, sum [HashSize]byte)

SetFileHash sets the hash returned by FileHash for file.

Types

type ActionID

type ActionID [HashSize]byte

An ActionID is a cache action key, the hash of a complete description of a repeatable computation (command line, environment variables, input file contents, executable contents).

func Subkey

func Subkey(parent ActionID, desc