cas

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cas implements a content-addressed store on the local filesystem. Objects are identified by "sha256:<hex>" and stored under <root>/sha256/<hex[0:2]>/<hex[2:4]>/<hex>. Writes go to a temp file in the root and are renamed into place, so a crash never leaves a partial object at its final path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a content-addressed object store rooted at a directory.

func Open

func Open(root string) (*Store, error)

Open creates the root directory if needed and returns a Store over it.

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes the object. Missing objects return an error satisfying os.IsNotExist; malformed ids return a non-nil error.

func (*Store) Get

func (s *Store) Get(id string) (io.ReadCloser, error)

Get opens the object for reading. The error satisfies os.IsNotExist for missing objects; malformed ids return a non-nil error as well.

func (*Store) Has

func (s *Store) Has(id string) bool

Has reports whether the object exists. Malformed ids report false.

func (*Store) List

func (s *Store) List() ([]string, error)

List returns the ids of every stored object, in no particular order.

func (*Store) Put

func (s *Store) Put(r io.Reader) (string, error)

Put streams r into the store and returns its content id. Storing content that already exists is a cheap no-op.

func (*Store) TotalSize

func (s *Store) TotalSize() (int64, error)

TotalSize returns the sum of all stored object sizes in bytes.

Jump to

Keyboard shortcuts

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