Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a cache that stores blobs by a hash of their contents.
func NewCache ¶ added in v0.3.0
func NewCache(logger *zap.Logger, dir string, newHash func() hash.Hash, hashSize int64, now func() time.Time) (*Cache, error)
NewCache 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) Put ¶
Put stores the given file in the cache. It may read file twice. The content of file must not change between the two passes.
type KeyedCache ¶ added in v0.3.0
type KeyedCache struct {
// contains filtered or unexported fields
}
KeyedCache is a cache that stores blobs by a key.
func NewKeyedCache ¶ added in v0.3.0
func (*KeyedCache) Get ¶ added in v0.3.0
func (c *KeyedCache) Get(key string) (file io.ReadSeekCloser, entry KeyedEntry, err error)
Get looks up the ID in the cache and returns a reader if found.
func (*KeyedCache) Put ¶ added in v0.3.0
func (c *KeyedCache) Put(key string, file io.ReadSeeker) (ID, int64, error)
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 (*KeyedCache) Size ¶ added in v0.3.0
func (c *KeyedCache) Size() (int64, error)
Size returns the total size of the cache in bytes.
func (*KeyedCache) Trim ¶ added in v0.3.0
func (c *KeyedCache) Trim(maxBytes int64) error
Trim removes old cache entries that are likely not to be reused.