Documentation
¶
Overview ¶
Package rangecache stores byte ranges of blobs the node has already fetched.
The containerd content store is all-or-nothing: a blob is either committed whole or absent, so a peer cannot serve any part of a 1 GiB layer until it holds all of it. Under Artifact Streaming that makes a cold image unserveable between peers - every node reads a few KiB of OverlayBD index and every one of those reads has to go to origin. This cache holds the ranges a node actually fetched so they can be answered locally and served to peers long before any layer is complete.
Index ¶
- Variables
- type Cache
- func (c *Cache) Close() error
- func (c *Cache) Digests() []digest.Digest
- func (c *Cache) Full() bool
- func (c *Cache) Has(d digest.Digest, requested httprange.Range) bool
- func (c *Cache) HasAny(d digest.Digest) bool
- func (c *Cache) OpenRange(_ context.Context, d digest.Digest, requested httprange.Range) (io.ReadCloser, int64, error)
- func (c *Cache) Put(d digest.Digest, total, start int64, r io.Reader) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrFull = errors.New("rangecache: full")
ErrFull means a new blob was not admitted. Put leaves its reader untouched.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a disk-backed store of partial blob content. It is intentionally non-durable: entries are discarded on restart rather than revalidated, because a stale range served as authoritative would corrupt an image.
func New ¶
New prepares an empty cache rooted at dir. Any previous contents are removed: the interval index lives in memory, so leftover files cannot be trusted.
func (*Cache) HasAny ¶
HasAny reports whether any range of d is cached, which is enough to make this node a useful provider for it.
func (*Cache) OpenRange ¶
func (c *Cache) OpenRange(_ context.Context, d digest.Digest, requested httprange.Range) (io.ReadCloser, int64, error)
OpenRange satisfies streaming.LocalRangeStore. It returns ifaces.ErrNotFound unless the whole requested interval is cached, so a partial hit never produces a short body.