Documentation
¶
Index ¶
- Constants
- func WithLogger(lgr *slog.Logger) cacheOption
- func WithMaxSize(n int64) cacheOption
- func WithNow(f func() time.Time) cacheOption
- func WithTrimInterval(d time.Duration) cacheOption
- func WithTrimLimit(d time.Duration) cacheOption
- func WithTrimSize(n int64) cacheOption
- 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) Trim() error
- type Hash
- type ID
- type OutputID
Constants ¶
const ( DefaultMaxSize = 0 DefaultTrimInterval = 5 * time.Minute DefaultTrimLimit = 24 * time.Hour DefaultTrimSize = 100 << 20 )
const HashSize = sha256.Size
Variables ¶
This section is empty.
Functions ¶
func WithLogger ¶ added in v0.3.2
WithLogger sets the logger to the given Logger - iff it is not nil.
func WithMaxSize ¶ added in v0.3.1
func WithMaxSize(n int64) cacheOption
func WithTrimInterval ¶ added in v0.3.0
func WithTrimLimit ¶ added in v0.3.0
func WithTrimSize ¶ added in v0.3.0
func WithTrimSize(n int64) cacheOption
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.
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. |