cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2018 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ConnectTimeout = 10 * time.Second
	ReadTimeout    = 10 * time.Second
	WriteTimeout   = 10 * time.Second
)

Constants for timeouts.

Variables

View Source
var (
	// ErrorLayerNotFound is the error returned by Lookup when the layer
	// requested was not found in the registry.
	ErrorLayerNotFound = errors.Errorf("layer not found in cache")
)

Functions

This section is empty.

Types

type KVStore

type KVStore interface {
	Get(string) (string, error)
	Put(string, string) error
	Cleanup() error
}

KVStore is the interface that the CacheManager relies on to make the mapping between cacheID and image name. The Get function returns an empty string and no error if the key was not found in the store. Cleanup closes potential connections to the store.

func NewFSStore

func NewFSStore(root string) KVStore

NewFSStore returns a KVStore backed by the local filesystem. Each key stored will correspond to a file on disk and its value is the contents of that key.

func NewRedisStore

func NewRedisStore(addr string, ttlsec int) (KVStore, error)

NewRedisStore returns a new instance of KVStore backed by a redis server. In this constructor we try to open a connection to redis. If that attempt fails we return an error. If it succeeds we just close that connection.

type Manager

type Manager interface {
	PullCache(cacheID string) (*image.DigestPair, error)
	PushCache(cacheID string, digestPair *image.DigestPair) error
	WaitForPush() error
}

Manager is the interface through which we interact with the cacheID -> image layer mapping.

func New

func New(cacheIDStore KVStore, target image.Name, registryClient registry.Client) Manager

New returns a new cache manager that interacts with the registry passed in as well as the local filesystem through the image store. By default the registry field is left blank.

func NewNoopCacheManager

func NewNoopCacheManager() Manager

NewNoopCacheManager returns a Manager that does nothing.

type MemKVStore

type MemKVStore map[string]string

MemKVStore implements the KVStore interface. It stores the key-value mappings in memory.

func (MemKVStore) Cleanup

func (m MemKVStore) Cleanup() error

Cleanup does nothing, but is implemented to comply with the KVStore interface.

func (MemKVStore) Get

func (m MemKVStore) Get(key string) (string, error)

Get returns the value of a key previously set in memory.

func (MemKVStore) Put

func (m MemKVStore) Put(key, value string) error

Put stores a key and its value in memory.

Jump to

Keyboard shortcuts

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