cache

package
v0.0.0-...-f09cf9b Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitialSize             = 1000
	RelativeInitialSize     = 100
	MinimumIndexGrowthDelta = 2000
)
View Source
const DefaultDeletionInterval = 3 * time.Second

Variables

This section is empty.

Functions

func NewNoopCache

func NewNoopCache(vecForID common.VectorForID[float32], maxSize int,
	logger logrus.FieldLogger,
) *noopCache

Types

type Cache

type Cache[T any] interface {
	MultiCache[T]
	Get(ctx context.Context, id uint64) ([]T, error)
	MultiGet(ctx context.Context, ids []uint64) ([][]T, []error)
	GetAllInCurrentLock(ctx context.Context, id uint64, out [][]T, errs []error) ([][]T, []error, uint64, uint64)
	PageSize() uint64
	Len() int32
	CountVectors() int64
	Delete(ctx context.Context, id uint64)
	Preload(id uint64, vec []T)
	PreloadNoLock(id uint64, vec []T)
	SetSizeAndGrowNoLock(id uint64)
	Prefetch(id uint64)
	Grow(size uint64)
	Drop()
	UpdateMaxSize(size int64)
	CopyMaxSize() int64
	All() [][]T
	LockAll()
	UnlockAll()
}

func NewShardedByteLockCache

func NewShardedByteLockCache(vecForID common.VectorForID[byte], maxSize int, pageSize uint64,
	logger logrus.FieldLogger, deletionInterval time.Duration,
	allocChecker memwatch.AllocChecker,
) Cache[byte]

func NewShardedFloat32LockCache

func NewShardedFloat32LockCache(vecForID common.VectorForID[float32], maxSize int, pageSize uint64,
	logger logrus.FieldLogger, normalizeOnRead bool, deletionInterval time.Duration,
	allocChecker memwatch.AllocChecker,
) Cache[float32]

func NewShardedMultiFloat32LockCache

func NewShardedMultiFloat32LockCache(multipleVecForID common.VectorForID[[]float32], maxSize int,
	logger logrus.FieldLogger, normalizeOnRead bool, deletionInterval time.Duration,
	allocChecker memwatch.AllocChecker,
) Cache[float32]

func NewShardedMultiUInt64LockCache

func NewShardedMultiUInt64LockCache(multipleVecForID common.VectorForID[uint64], maxSize int,
	logger logrus.FieldLogger, deletionInterval time.Duration,
	allocChecker memwatch.AllocChecker,
) Cache[uint64]

func NewShardedUInt64LockCache

func NewShardedUInt64LockCache(vecForID common.VectorForID[uint64], maxSize int, pageSize uint64,
	logger logrus.FieldLogger, deletionInterval time.Duration,
	allocChecker memwatch.AllocChecker,
) Cache[uint64]

type CacheKeys

type CacheKeys struct {
	DocID      uint64
	RelativeID uint64
}

type MultiCache

type MultiCache[T any] interface {
	PreloadMulti(docID uint64, ids []uint64, vecs [][]T)
	GetKeys(id uint64) (uint64, uint64)
	SetKeys(id uint64, docID uint64, relativeID uint64)
	GrowMultiCache(id uint64)
	AllMulti() [][][]T
}

Jump to

Keyboard shortcuts

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