caching

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: ISC Imports: 15 Imported by: 4

Documentation

Index

Constants

View Source
const CACHE_VERSION = "2.0.0"

Variables

View Source
var (
	ErrClosed = fmt.Errorf("cache closed")
)

Functions

This section is empty.

Types

type Batch added in v1.0.10

type Batch interface {
	Put([]byte, []byte) error
	Count() uint32
	Commit() error
}

This is not goroutine safe, external synchronization must be provided.

type Cache added in v1.0.10

type Cache interface {
	Put([]byte, []byte) error
	Has([]byte) (bool, error)
	Get([]byte) ([]byte, error)

	// Must support Delete during Scan
	Delete([]byte) error

	// reverse is only to accomodate EnumerateKeysWithPrefix, once
	// that doesn't need it anymore this can become simpler again.
	// key returned by an iteration might get invalidated on
	// subsequent iterations.
	Scan([]byte, bool) iter.Seq2[[]byte, []byte]

	NewBatch() Batch

	Close() error
}

type CheckCache

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

func (*CheckCache) Close

func (c *CheckCache) Close() error

func (*CheckCache) GetChunkStatus

func (c *CheckCache) GetChunkStatus(mac objects.MAC) ([]byte, error)

func (*CheckCache) GetObjectStatus

func (c *CheckCache) GetObjectStatus(mac objects.MAC) ([]byte, error)

func (*CheckCache) GetPackfileStatus

func (c *CheckCache) GetPackfileStatus(mac objects.MAC) ([]byte, error)

func (*CheckCache) GetVFSEntryStatus

func (c *CheckCache) GetVFSEntryStatus(mac objects.MAC) ([]byte, error)

func (*CheckCache) GetVFSStatus

func (c *CheckCache) GetVFSStatus(mac objects.MAC) ([]byte, error)

func (*CheckCache) PutChunkStatus

func (c *CheckCache) PutChunkStatus(mac objects.MAC, err []byte) error

func (*CheckCache) PutObjectStatus

func (c *CheckCache) PutObjectStatus(mac objects.MAC, err []byte) error

func (*CheckCache) PutPackfileStatus

func (c *CheckCache) PutPackfileStatus(mac objects.MAC, err []byte) error

func (*CheckCache) PutVFSEntryStatus

func (c *CheckCache) PutVFSEntryStatus(mac objects.MAC, err []byte) error

func (*CheckCache) PutVFSStatus

func (c *CheckCache) PutVFSStatus(mac objects.MAC, err []byte) error

type Constructor added in v1.0.10

type Constructor func(version, name, repoid string, opts Option) (Cache, error)

type DBStore

type DBStore[K any, V any] struct {
	Prefix string

	Cache *ScanCache
	// contains filtered or unexported fields
}

DBStore implements btree.Storer

func (*DBStore[K, V]) Close added in v1.0.13

func (ds *DBStore[K, V]) Close() error

func (*DBStore[K, V]) Get

func (ds *DBStore[K, V]) Get(idx int) (*btree.Node[K, int, V], error)

func (*DBStore[K, V]) Put

func (ds *DBStore[K, V]) Put(node *btree.Node[K, int, V]) (int, error)

func (*DBStore[K, V]) Update

func (ds *DBStore[K, V]) Update(idx int, node *btree.Node[K, int, V]) error

type MaintenanceCache

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

func (*MaintenanceCache) Close added in v1.0.10

func (c *MaintenanceCache) Close() error

func (*MaintenanceCache) DeleletePackfiles

func (c *MaintenanceCache) DeleletePackfiles(snapshotID objects.MAC) error

func (*MaintenanceCache) DeleteSnapshot

func (c *MaintenanceCache) DeleteSnapshot(snapshotID objects.MAC) error

func (*MaintenanceCache) GetPackfiles

func (c *MaintenanceCache) GetPackfiles(snapshotID objects.MAC) iter.Seq[objects.MAC]

func (*MaintenanceCache) HasPackfile

func (c *MaintenanceCache) HasPackfile(packfileMAC objects.MAC) bool

func (*MaintenanceCache) HasSnapshot

func (c *MaintenanceCache) HasSnapshot(snapshotID objects.MAC) (bool, error)

func (*MaintenanceCache) PutPackfile

func (c *MaintenanceCache) PutPackfile(snapshotID, packfileMAC objects.MAC) error

func (*MaintenanceCache) PutSnapshot

func (c *MaintenanceCache) PutSnapshot(snapshotID objects.MAC, data []byte) error

type Manager

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

func NewManager

func NewManager(cons Constructor) *Manager

func (*Manager) Check

func (m *Manager) Check() (*CheckCache, error)

XXX - beware that caller has responsibility to call Close() on the returned cache

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Maintenance

func (m *Manager) Maintenance(repositoryID uuid.UUID) (*MaintenanceCache, error)

func (*Manager) Packing

func (m *Manager) Packing() (*PackingCache, error)

XXX - beware that caller has responsibility to call Close() on the returned cache

func (*Manager) Repository

func (m *Manager) Repository(repositoryID uuid.UUID) (*_RepositoryCache, error)

func (*Manager) Scan

func (m *Manager) Scan(snapshotID objects.MAC) (*ScanCache, error)

XXX - beware that caller has responsibility to call Close() on the returned cache

type Option added in v1.0.10

type Option int
const (
	None Option = iota

	DeleteOnClose
)

type PackingCache

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

func (*PackingCache) Close

func (c *PackingCache) Close() error

func (*PackingCache) GetIndexesBlob

func (c *PackingCache) GetIndexesBlob() iter.Seq[[]byte]

func (*PackingCache) HasBlob

func (c *PackingCache) HasBlob(Type resources.Type, mac objects.MAC) (bool, error)

func (*PackingCache) PutBlob

func (c *PackingCache) PutBlob(Type resources.Type, mac objects.MAC) error

func (*PackingCache) PutIndexBlob

func (c *PackingCache) PutIndexBlob(Type resources.Type, mac objects.MAC, data []byte) error

type SQLState added in v1.1.0

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

func NewSQLState added in v1.1.0

func NewSQLState(path string, ro bool) (*SQLState, error)

func (*SQLState) DelColoured added in v1.1.0

func (c *SQLState) DelColoured(blobType resources.Type, blobCsum objects.MAC) error

func (*SQLState) DelDelta added in v1.1.0

func (c *SQLState) DelDelta(blobType resources.Type, blobCsum, packfileMAC objects.MAC) error

func (*SQLState) DelPackfile added in v1.1.0

func (c *SQLState) DelPackfile(packfile objects.MAC) error

func (*SQLState) DelState added in v1.1.0

func (c *SQLState) DelState(stateID objects.MAC) error

func (*SQLState) GetColouredEntries added in v1.1.0

func (c *SQLState) GetColouredEntries() iter.Seq2[objects.MAC, []byte]

func (*SQLState) GetColouredEntriesByType added in v1.1.0

func (c *SQLState) GetColouredEntriesByType(blobType resources.Type) iter.Seq2[objects.MAC, []byte]

func (*SQLState) GetConfiguration added in v1.1.0

func (c *SQLState) GetConfiguration(key string) ([]byte, error)

func (*SQLState) GetConfigurations added in v1.1.0

func (c *SQLState) GetConfigurations() iter.Seq[[]byte]

func (*SQLState) GetDeletedEntries added in v1.1.0

func (c *SQLState) GetDeletedEntries() iter.Seq[[]byte]

func (*SQLState) GetDelta added in v1.1.0

func (c *SQLState) GetDelta(blobType resources.Type, blobCsum objects.MAC) iter.Seq2[objects.MAC, []byte]

func (*SQLState) GetDeltas added in v1.1.0

func (c *SQLState) GetDeltas() iter.Seq2[objects.MAC, []byte]

func (*SQLState) GetDeltasByType added in v1.1.0

func (c *SQLState) GetDeltasByType(blobType resources.Type) iter.Seq2[objects.MAC, []byte]

func (*SQLState) GetLatestState added in v1.1.0

func (c *SQLState) GetLatestState() (objects.MAC, error)

func (*SQLState) GetPackfiles added in v1.1.0

func (c *SQLState) GetPackfiles() iter.Seq2[objects.MAC, []byte]

func (*SQLState) GetState added in v1.1.0

func (c *SQLState) GetState(stateID objects.MAC) ([]byte, error)

func (*SQLState) GetStates added in v1.1.0

func (c *SQLState) GetStates() (map[objects.MAC][]byte, error)

func (*SQLState) HasColoured added in v1.1.0

func (c *SQLState) HasColoured(blobType resources.Type, blobCsum objects.MAC) (bool, error)

func (*SQLState) HasPackfile added in v1.1.0

func (c *SQLState) HasPackfile(packfile objects.MAC) (bool, error)

func (*SQLState) HasState added in v1.1.0

func (c *SQLState) HasState(stateID objects.MAC) (bool, error)

func (*SQLState) NewBatch added in v1.1.0

func (c *SQLState) NewBatch() StateBatch

func (*SQLState) PutColoured added in v1.1.0

func (c *SQLState) PutColoured(blobType resources.Type, blobCsum objects.MAC, data []byte) error

func (*SQLState) PutConfiguration added in v1.1.0

func (c *SQLState) PutConfiguration(key string, data []byte) error

Configuration handling

func (*SQLState) PutDeleted added in v1.1.0

func (c *SQLState) PutDeleted(typ uint8, blobCsum objects.MAC, data []byte) error

Those two are only to construct deltas, when working with the local state we do the actual deletion.

func (*SQLState) PutDelta added in v1.1.0

func (c *SQLState) PutDelta(blobType resources.Type, blobCsum, packfile objects.MAC, data []byte) error

func (*SQLState) PutPackfile added in v1.1.0

func (c *SQLState) PutPackfile(packfile objects.MAC, data []byte) error

Packfile handling

func (*SQLState) PutState added in v1.1.0

func (c *SQLState) PutState(stateID objects.MAC, data []byte) error

States handling, mostly unused.

type SQLiteDBStore added in v1.0.13

type SQLiteDBStore[K any, V any] struct {
	// contains filtered or unexported fields
}

SQLiteDBStore implements btree.Storer

func NewSQLiteDBStore added in v1.0.13

func NewSQLiteDBStore[K, V any](storePath, storeName string) (*SQLiteDBStore[K, V], error)

func (*SQLiteDBStore[K, V]) Close added in v1.0.13

func (ds *SQLiteDBStore[K, V]) Close() error

func (*SQLiteDBStore[K, V]) Get added in v1.0.13

func (ds *SQLiteDBStore[K, V]) Get(idx int) (*btree.Node[K, int, V], error)

func (*SQLiteDBStore[K, V]) Put added in v1.0.13

func (ds *SQLiteDBStore[K, V]) Put(node *btree.Node[K, int, V]) (int, error)

func (*SQLiteDBStore[K, V]) Update added in v1.0.13

func (ds *SQLiteDBStore[K, V]) Update(idx int, node *btree.Node[K, int, V]) error

type ScanBatch added in v1.0.10

type ScanBatch struct {
	Batch
}

func (*ScanBatch) PutDelta added in v1.0.10

func (c *ScanBatch) PutDelta(blobType resources.Type, blobCsum, packfile objects.MAC, data []byte) error

func (*ScanBatch) PutDirectory added in v1.0.10

func (c *ScanBatch) PutDirectory(source int, directory string, data []byte) error

func (*ScanBatch) PutFile added in v1.0.10

func (c *ScanBatch) PutFile(source int, file string, data []byte) error

type ScanCache

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

func (*ScanCache) Close

func (c *ScanCache) Close() error

func (*ScanCache) DelColoured added in v1.1.0

func (c *ScanCache) DelColoured(blobType resources.Type, blobCsum objects.MAC) error

func (*ScanCache) DelDelta

func (c *ScanCache) DelDelta(blobType resources.Type, blobCsum, packfileMAC objects.MAC) error

func (*ScanCache) DelPackfile

func (c *ScanCache) DelPackfile(packfile objects.MAC) error

func (*ScanCache) DelState

func (c *ScanCache) DelState(stateID objects.MAC) error

func (*ScanCache) EnumerateKeysWithPrefix

func (c *ScanCache) EnumerateKeysWithPrefix(prefix string, reverse bool) iter.Seq2[string, []byte]

func (*ScanCache) GetColouredEntries added in v1.1.0

func (c *ScanCache) GetColouredEntries() iter.Seq2[objects.MAC, []byte]

func (*ScanCache) GetColouredEntriesByType added in v1.1.0

func (c *ScanCache) GetColouredEntriesByType(blobType resources.Type) iter.Seq2[objects.MAC, []byte]

func (*ScanCache) GetConfiguration

func (c *ScanCache) GetConfiguration(key string) ([]byte, error)

func (*ScanCache) GetConfigurations

func (c *ScanCache) GetConfigurations() iter.Seq[[]byte]

func (*ScanCache) GetDeletedEntries added in v1.1.0

func (c *ScanCache) GetDeletedEntries() iter.Seq[[]byte]

func (*ScanCache) GetDelta

func (c *ScanCache) GetDelta(blobType resources.Type, blobCsum objects.MAC) iter.Seq2[objects.MAC, []byte]

func (*ScanCache) GetDeltas

func (c *ScanCache) GetDeltas() iter.Seq2[objects.MAC, []byte]

func (*ScanCache) GetDeltasByType

func (c *ScanCache) GetDeltasByType(blobType resources.Type) iter.Seq2[objects.MAC, []byte]

func (*ScanCache) GetDirectory

func (c *ScanCache) GetDirectory(source int, directory string) ([]byte, error)

func (*ScanCache) GetFile

func (c *ScanCache) GetFile(source int, file string) ([]byte, error)

func (*ScanCache) GetLatestState added in v1.1.0

func (c *ScanCache) GetLatestState() (objects.MAC, error)

func (*ScanCache) GetPackfiles

func (c *ScanCache) GetPackfiles() iter.Seq2[objects.MAC, []byte]

func (*ScanCache) GetState

func (c *ScanCache) GetState(stateID objects.MAC) ([]byte, error)

func (*ScanCache) GetStates

func (c *ScanCache) GetStates() (map[objects.MAC][]byte, error)

func (*ScanCache) HasColoured added in v1.1.0

func (c *ScanCache) HasColoured(blobType resources.Type, blobCsum objects.MAC) (bool, error)

func (*ScanCache) HasPackfile

func (c *ScanCache) HasPackfile(packfile objects.MAC) (bool, error)

func (*ScanCache) HasState

func (c *ScanCache) HasState(stateID objects.MAC) (bool, error)

func (*ScanCache) NewBatch added in v1.0.10

func (c *ScanCache) NewBatch() StateBatch

func (*ScanCache) NewScanBatch added in v1.0.10

func (c *ScanCache) NewScanBatch() *ScanBatch

func (*ScanCache) PutColoured added in v1.1.0

func (c *ScanCache) PutColoured(blobType resources.Type, blobCsum objects.MAC, data []byte) error

func (*ScanCache) PutConfiguration

func (c *ScanCache) PutConfiguration(key string, data []byte) error

func (*ScanCache) PutDeleted

func (c *ScanCache) PutDeleted(typ uint8, blobCsum objects.MAC, data []byte) error

Those two are only to construct deltas, when working with the local state we do the actual deletion.

func (*ScanCache) PutDelta

func (c *ScanCache) PutDelta(blobType resources.Type, blobCsum, packfile objects.MAC, data []byte) error

func (*ScanCache) PutDirectory

func (c *ScanCache) PutDirectory(source int, directory string, data []byte) error

func (*ScanCache) PutFile

func (c *ScanCache) PutFile(source int, file string, data []byte) error

func (*ScanCache) PutPackfile

func (c *ScanCache) PutPackfile(packfile objects.MAC, data []byte) error

func (*ScanCache) PutState

func (c *ScanCache) PutState(stateID objects.MAC, data []byte) error

type StateBatch added in v1.0.10

type StateBatch interface {
	Batch
	PutDelta(blobType resources.Type, blobCsum, packfile objects.MAC, data []byte) error
}

type StateCache

type StateCache interface {
	PutState(stateID objects.MAC, data []byte) error
	HasState(stateID objects.MAC) (bool, error)
	GetState(stateID objects.MAC) ([]byte, error)
	GetLatestState() (objects.MAC, error)
	DelState(stateID objects.MAC) error
	GetStates() (map[objects.MAC][]byte, error)

	PutDelta(blobType resources.Type, blobCsum, packfile objects.MAC, data []byte) error
	GetDelta(blobType resources.Type, blobCsum objects.MAC) iter.Seq2[objects.MAC, []byte]
	GetDeltasByType(blobType resources.Type) iter.Seq2[objects.MAC, []byte]
	GetDeltas() iter.Seq2[objects.MAC, []byte]
	DelDelta(blobType resources.Type, blobCsum objects.MAC, packfileMAC objects.MAC) error

	// Solely for delta state construction.
	PutDeleted(typ uint8, blobCsum objects.MAC, data []byte) error
	GetDeletedEntries() iter.Seq[[]byte]

	PutColoured(blobType resources.Type, blobCsum objects.MAC, data []byte) error
	HasColoured(blobType resources.Type, blobCsum objects.MAC) (bool, error)
	DelColoured(blobType resources.Type, blobCsum objects.MAC) error
	GetColouredEntriesByType(blobType resources.Type) iter.Seq2[objects.MAC, []byte]
	GetColouredEntries() iter.Seq2[objects.MAC, []byte]

	PutPackfile(packfile objects.MAC, data []byte) error
	DelPackfile(packfile objects.MAC) error
	HasPackfile(packfile objects.MAC) (bool, error)
	GetPackfiles() iter.Seq2[objects.MAC, []byte]

	PutConfiguration(key string, data []byte) error
	GetConfiguration(key string) ([]byte, error)
	GetConfigurations() iter.Seq[[]byte]

	NewBatch() StateBatch
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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