Documentation
¶
Index ¶
- Constants
- type ActionID
- type Cache
- func (C *Cache) Get(id ActionID) (cache.Entry, error)
- func (C *Cache) GetBytes(id ActionID) ([]byte, cache.Entry, error)
- func (C *Cache) GetFile(id ActionID) (file string, entry cache.Entry, err error)
- func (C *Cache) Put(id ActionID, file io.ReadSeeker) (OutputID, int64, error)
- func (C *Cache) SetTrimInterval(d time.Duration)
- func (C *Cache) SetTrimLimit(d time.Duration)
- func (C *Cache) SetTrimSize(n int64)
- func (C *Cache) Trim() error
- type Hash
- type ID
- type OutputID
Constants ¶
const HashSize = sha256.Size
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionID ¶
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 NewActionID ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
A Cache is a package cache, backed by a file system directory tree.
func Open ¶
Open opens and returns the cache in the given directory.
It is safe for multiple processes on a single machine to use the same cache directory in a local file system simultaneously. They will coordinate using operating system file locks and may duplicate effort but will not corrupt the cache.
However, it is NOT safe for multiple processes on different machines to share a cache directory (for example, if the directory were stored in a network file system). File locking is notoriously unreliable in network file systems and may not suffice to protect the cache.
func (*Cache) Get ¶
Get looks up the action ID in the cache, returning the corresponding output ID and file size, if any. Note that finding an output ID does not guarantee that the saved file for that output ID is still available.
func (*Cache) GetBytes ¶
GetBytes looks up the action ID in the cache and returns the corresponding output bytes. GetBytes should only be used for data that can be expected to fit in memory.
func (*Cache) GetFile ¶
GetFile looks up the action ID in the cache and returns the name of the corresponding data file.
func (*Cache) Put ¶
Put stores the given output in the cache as the output for the action ID. It may read file twice. The content of file must not change between the two passes.
func (*Cache) SetTrimInterval ¶ added in v0.2.0
SetTrimInterval set the time intervals between Trims (on Put).
func (*Cache) SetTrimLimit ¶ added in v0.2.0
SetTrimLimit set the max age of entries.
func (*Cache) SetTrimSize ¶ added in v0.2.0
SetTrimSize set the trim file size (checked on Put).
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
filecache
Package main of filecache implements program memoization: caches the output of the call with the arguments (and possibly the stdin) as key.
|
Package main of filecache implements program memoization: caches the output of the call with the arguments (and possibly the stdin) as key. |