backends

package
v0.0.0-...-c3c3f30 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const GobBackendName string = "gob"

Variables

This section is empty.

Functions

func GobCacheDir

func GobCacheDir(prefix string, gitRootPath string) string

func GobCacheFilename

func GobCacheFilename(stateHash string) string

Types

type GobBackend

type GobBackend struct {
	Dir  string
	Path string
	// contains filtered or unexported fields
}

Stores commits on disk at a particular filepath.

Commits are stored in Gob format. The file stored on disk is a series of Gob-encoded arrays, each prefixed with a four-byte value indicating the number of bytes in the next array. This framing creates redundancy (since the Gob type metadata is repeated for each array) but allows us to append to the file on disk instead of replacing the whole file when we want to cache new commits.

The Gob backend produces a cache file roughly half the size of the JSON backend on disk. It's also SIGNIFICANTLY faster to read the cache from disk when in Gob format rather than JSON format.

We also gzip the file when we're done using it to keep it even smaller on disk.

func (*GobBackend) Add

func (b *GobBackend) Add(commits []git.Commit) (err error)

func (*GobBackend) Clear

func (b *GobBackend) Clear() error

func (*GobBackend) Close

func (b *GobBackend) Close() error

func (*GobBackend) Get

func (b *GobBackend) Get(revs []string) (iter.Seq[git.Commit], func() error)

func (*GobBackend) Name

func (b *GobBackend) Name() string

func (*GobBackend) Open

func (b *GobBackend) Open() error

type JSONBackend

type JSONBackend struct {
	Path string
}

Stores commits on disk at a particular filepath.

Commits are stored as newline-delimited JSON. For now, all commits that match the revs being searched for are loaded into memory before being returned.

func (JSONBackend) Add

func (b JSONBackend) Add(commits []git.Commit) (err error)

func (JSONBackend) Clear

func (b JSONBackend) Clear() error

func (JSONBackend) Close

func (b JSONBackend) Close() error

func (JSONBackend) Get

func (b JSONBackend) Get(revs []string) (iter.Seq[git.Commit], func() error)

Reads all commits into memory!

func (JSONBackend) Name

func (b JSONBackend) Name() string

func (JSONBackend) Open

func (b JSONBackend) Open() error

type NoopBackend

type NoopBackend struct{}

func (NoopBackend) Add

func (b NoopBackend) Add(commits []git.Commit) error

func (NoopBackend) Clear

func (b NoopBackend) Clear() error

func (NoopBackend) Close

func (b NoopBackend) Close() error

func (NoopBackend) Get

func (b NoopBackend) Get(revs []string) (iter.Seq[git.Commit], func() error)

func (NoopBackend) Name

func (b NoopBackend) Name() string

func (NoopBackend) Open

func (b NoopBackend) Open() error

Jump to

Keyboard shortcuts

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