cache

package
v0.0.0-...-3e667ac Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongState = errors.New("wrong state of cache writer")

ErrWrongState is returned when the entry writer is in the wrong state, for example the user attempts to discard an already committed writer.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	IsCached(context.Context, digest.Digest) (bool, error)

	Open(context.Context, digest.Digest) (io.ReadCloser, int64, error)
	Create(context.Context) (EntryWriter, error)

	ReadMeta(context.Context, digest.Digest, string) ([]byte, error)
}

A Cache stores blobs and makes them available using their digest.

func DefaultCache

func DefaultCache() (Cache, error)

DefaultCache returns a Cache configured to use the local file system in the user preferred location.

On Linux, this is usually $HOME/.cache/vinci/v1/.

func InDirectory

func InDirectory(dir string) Cache

func NewMemCache

func NewMemCache() Cache

type EntryWriter

type EntryWriter interface {
	io.Writer
	io.Closer

	Digest() digest.Digest
	Size() int64
	Commit() error
	Discard() error

	SetMeta(context.Context, string, []byte) error
}

EntryWriter is used to control the actual submission of a blob to a cache. The following protocol is to be used when an EntryWriter is returned:

* Write() to the io.Writer part. * Close() the file via io.Closer. After closing, the digest can be retrieved via Digest(), the written size via Size().

If the entry is to be committed into the store, use Commit(), otherwise, use Discard().

For cases where the final call to Commit() or Discard() is missing, the cache SHOULD offer a way to discard accrued garbage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL