cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache implements DVC's content-addressed object store (.dvc/cache/files/md5/<2>/<rest>) with atomic writes and 0o444 protection.

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 content-addressed store rooted at a .dvc/cache directory.

func New

func New(dir string) *Cache

New returns a Cache rooted at dir (typically <repo>/.dvc/cache).

func (*Cache) AddBytes

func (c *Cache) AddBytes(data []byte, oid string) error

AddBytes stores data under oid (no-op if already present).

func (*Cache) AddFile

func (c *Cache) AddFile(src, oid string) error

AddFile copies the file at src into the cache under oid (no-op if present).

func (*Cache) Adopt

func (c *Cache) Adopt(src, oid string) error

Adopt moves an already-materialized file (e.g. a verified download) into the cache under oid via an atomic rename, applying read-only protection. src must live on the same filesystem as the cache.

func (*Cache) AllObjects

func (c *Cache) AllObjects() ([]string, error)

AllObjects returns every object id currently stored in the cache.

func (*Cache) Has

func (c *Cache) Has(oid string) bool

Has reports whether the object is present in the cache.

func (*Cache) LegacyPath

func (c *Cache) LegacyPath(oid string) string

LegacyPath returns the DVC 2.x cache path for an object id (.dvc/cache/<2>/<rest>, the layout used before the files/md5 split).

func (*Cache) ObjectPath

func (c *Cache) ObjectPath(oid string) string

ObjectPath returns the on-disk path for an object id. The id may carry a ".dir" suffix for directory manifests; the two-char prefix split matches DVC.

func (*Cache) Remove

func (c *Cache) Remove(oid string) error

Remove deletes an object from the cache.

func (*Cache) ResolveRead

func (c *Cache) ResolveRead(oid string) (string, bool)

ResolveRead returns the path of an existing object, preferring the modern 3.x layout and falling back to the legacy 2.x layout. This is read-only: lode always writes new objects in the modern layout.

func (*Cache) Size

func (c *Cache) Size(oid string) int64

Size returns the byte size of the object, or 0 if absent.

func (*Cache) TempDir

func (c *Cache) TempDir() string

TempDir returns a scratch directory on the same filesystem as the cache, suitable for downloads that will be renamed into place via Adopt.

Jump to

Keyboard shortcuts

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