Documentation
¶
Overview ¶
Package store provides content-addressable storage implementations.
Index ¶
- type CAFS
- func (c *CAFS) Delete(ctx context.Context, h contentcache.Hash) error
- func (c *CAFS) Get(ctx context.Context, h contentcache.Hash) (io.ReadCloser, error)
- func (c *CAFS) GetBytes(ctx context.Context, h contentcache.Hash) ([]byte, error)
- func (c *CAFS) GetFramed(ctx context.Context, h contentcache.Hash) (*backend.BlobHeader, io.ReadCloser, error)
- func (c *CAFS) Has(ctx context.Context, h contentcache.Hash) (bool, error)
- func (c *CAFS) List(ctx context.Context) ([]contentcache.Hash, error)
- func (c *CAFS) Put(ctx context.Context, r io.Reader) (contentcache.Hash, error)
- func (c *CAFS) PutBytes(ctx context.Context, data []byte) (contentcache.Hash, error)
- func (c *CAFS) PutFramed(ctx context.Context, header *backend.BlobHeader, body io.Reader) (contentcache.Hash, error)
- func (c *CAFS) PutWithResult(ctx context.Context, r io.Reader) (*PutResult, error)
- func (c *CAFS) Size(ctx context.Context, h contentcache.Hash) (int64, error)
- type CAFSOption
- type ExtendedStore
- type MetadataTracker
- type PutResult
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CAFS ¶
type CAFS struct {
// contains filtered or unexported fields
}
CAFS implements content-addressable file storage. Content is stored in a sharded directory structure based on hash.
func NewCAFS ¶
func NewCAFS(b backend.Backend, opts ...CAFSOption) *CAFS
NewCAFS creates a new content-addressable file store.
func (*CAFS) Get ¶
func (c *CAFS) Get(ctx context.Context, h contentcache.Hash) (io.ReadCloser, error)
Get retrieves content by its hash.
func (*CAFS) GetFramed ¶ added in v1.2.0
func (c *CAFS) GetFramed(ctx context.Context, h contentcache.Hash) (*backend.BlobHeader, io.ReadCloser, error)
GetFramed retrieves content with its headers.
func (*CAFS) PutFramed ¶ added in v1.2.0
func (c *CAFS) PutFramed(ctx context.Context, header *backend.BlobHeader, body io.Reader) (contentcache.Hash, error)
PutFramed stores content with headers and returns its hash.
func (*CAFS) PutWithResult ¶
PutWithResult stores content and returns detailed information. Uses a temp file to avoid memory exhaustion for large content.
type CAFSOption ¶
type CAFSOption func(*CAFS)
CAFSOption configures a CAFS instance.
func WithMetaDB ¶ added in v1.2.0
func WithMetaDB(db metadb.MetaDB) CAFSOption
WithMetaDB sets a MetaDB for blob tracking.
func WithMetadataTracker ¶
func WithMetadataTracker(tracker MetadataTracker) CAFSOption
WithMetadataTracker sets a metadata tracker for expiration support.
type ExtendedStore ¶
type ExtendedStore interface {
Store
// PutWithResult stores content and returns detailed information.
PutWithResult(ctx context.Context, r io.Reader) (*PutResult, error)
// List returns all hashes in the store.
// This may be expensive for large stores.
List(ctx context.Context) ([]contentcache.Hash, error)
}
ExtendedStore provides additional operations beyond the basic Store.
type MetadataTracker ¶
type MetadataTracker interface {
// Create records metadata for a new blob.
Create(ctx context.Context, hash contentcache.Hash, size int64) error
// Touch updates the last access time for a blob.
Touch(ctx context.Context, hash contentcache.Hash) error
// Delete removes metadata for a blob.
Delete(ctx context.Context, hash contentcache.Hash) error
}
MetadataTracker tracks blob metadata for expiration.
type PutResult ¶
type PutResult struct {
Hash contentcache.Hash
Size int64
Exists bool // true if the content already existed
}
PutResult contains information about a Put operation.
type Store ¶
type Store interface {
// Put stores content and returns its hash.
// If the content already exists (same hash), this is a no-op.
Put(ctx context.Context, r io.Reader) (contentcache.Hash, error)
// Get retrieves content by its hash.
// Returns ErrNotFound if the hash does not exist.
// The caller must close the returned ReadCloser.
Get(ctx context.Context, h contentcache.Hash) (io.ReadCloser, error)
// Has checks if content with the given hash exists.
Has(ctx context.Context, h contentcache.Hash) (bool, error)
// Delete removes content by its hash.
// Returns nil if the content does not exist (idempotent).
Delete(ctx context.Context, h contentcache.Hash) error
// Size returns the size of content with the given hash.
// Returns ErrNotFound if the hash does not exist.
Size(ctx context.Context, h contentcache.Hash) (int64, error)
}
Store provides content-addressable storage operations. Content is stored by its BLAKE3 hash, ensuring deduplication.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gc provides garbage collection for the content cache.
|
Package gc provides garbage collection for the content cache. |
|
Package metadb provides metadata storage using bbolt for the content cache.
|
Package metadb provides metadata storage using bbolt for the content cache. |