cache

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2015 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides facilities to speed up access to the storage backend. Typically cache implementations deal with internal implementation details at the backend level, rather than generalized caches for distribution related interfaces. In other words, unless the cache is specific to the storage package, it belongs in another package.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound is returned when a meta item is not found.

Functions

This section is empty.

Types

type LayerInfoCache

type LayerInfoCache interface {
	// Contains returns true if the repository with name contains the layer.
	Contains(ctx context.Context, repo string, dgst digest.Digest) (bool, error)

	// Add includes the layer in the given repository cache.
	Add(ctx context.Context, repo string, dgst digest.Digest) error

	Delete(ctx context.Context, repo string, dgst digest.Digest) error

	// Meta provides the location of the layer on the backend and its size. Membership of a
	// repository should be tested before using the result, if required.
	Meta(ctx context.Context, dgst digest.Digest) (LayerMeta, error)

	// SetMeta sets the meta data for the given layer.
	SetMeta(ctx context.Context, dgst digest.Digest, meta LayerMeta) error
}

LayerInfoCache is a driver-aware cache of layer metadata. Basically, it provides a fast cache for checks against repository metadata, avoiding round trips to backend storage. Note that this is different from a pure layer cache, which would also provide access to backing data, as well. Such a cache should be implemented as a middleware, rather than integrated with the storage backend.

Note that most implementations rely on the caller to do strict checks on on repo and dgst arguments, since these are mostly used behind existing implementations.

func NewInMemoryLayerInfoCache

func NewInMemoryLayerInfoCache() LayerInfoCache

NewInMemoryLayerInfoCache provides an implementation of LayerInfoCache that stores results in memory.

func NewRedisLayerInfoCache

func NewRedisLayerInfoCache(pool *redis.Pool) LayerInfoCache

NewRedisLayerInfoCache returns a new redis-based LayerInfoCache using the provided redis connection pool.

type LayerMeta

type LayerMeta struct {
	Path   string
	Length int64
}

LayerMeta describes the backend location and length of layer data.

Jump to

Keyboard shortcuts

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