cas

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BucketCAS     = "cas"
	BucketCASRefs = "cas_refs"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CASObject

type CASObject struct {
	CID  string // Content identifier (multihash)
	Data []byte // Object data
	Size int    // Size in bytes
}

CASObject represents a stored object in CAS

type CASRefCount

type CASRefCount struct {
	CID   string   `json:"cid"`
	Refs  int      `json:"refs"`
	Files []string `json:"files"` // Which files reference this CID
}

CASRefCount tracks references to a CAS object

type CASStats

type CASStats struct {
	TotalObjects     int
	TotalSize        int64
	TotalRefs        int
	UniqueFiles      int
	UnreferencedObjs int
}

Stats returns statistics about the CAS store

type CASStore

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

CASStore implements content-addressable storage

func NewCASStore

func NewCASStore(db *bbolt.DB, hashAlgo string) (*CASStore, error)

NewCASStore creates a new content-addressable storage instance

func (*CASStore) AddReference

func (c *CASStore) AddReference(cid, filePath string) error

AddReference adds a reference from a file to a CID

func (*CASStore) Delete

func (c *CASStore) Delete(cid string) error

Delete removes a CID from CAS WARNING: This should only be called after verifying no references exist

func (*CASStore) GarbageCollect

func (c *CASStore) GarbageCollect() (int, error)

GarbageCollect removes unreferenced CAS objects

func (*CASStore) Get

func (c *CASStore) Get(cid string) ([]byte, error)

Get retrieves data from CAS by CID

func (*CASStore) GetRefCount

func (c *CASStore) GetRefCount(cid string) (int, error)

GetRefCount returns the reference count for a CID

func (*CASStore) GetStats

func (c *CASStore) GetStats() (CASStats, error)

GetStats returns statistics about the CAS store

func (*CASStore) Has

func (c *CASStore) Has(cid string) (bool, error)

Has checks if a CID exists in CAS

func (*CASStore) Put

func (c *CASStore) Put(data []byte) (string, error)

Put stores data in CAS and returns its CID If the data already exists (same CID), it's deduplicated

func (*CASStore) RemoveReference

func (c *CASStore) RemoveReference(cid, filePath string) error

RemoveReference removes a reference from a file to a CID

Jump to

Keyboard shortcuts

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