store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: AGPL-3.0, Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Primary types
	GsfaPrimary       = "gsfaprimary"
	SigToEpochPrimary = "sig2epochprimary"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrDuplicate

type ErrDuplicate struct {
	Key         []byte
	StoredKey   []byte
	Value       []byte
	StoredValue []byte
}

func (*ErrDuplicate) Error

func (e *ErrDuplicate) Error() string

func (*ErrDuplicate) Is

func (e *ErrDuplicate) Is(err error) bool

Is returns true if the error is an ErrDuplicate.

type Iterator

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

Iterator iterates keys and values. Any write to the store potentially invalidates the iterator and may cause values to be missed or seen again.

func (*Iterator) Next

func (it *Iterator) Next() ([]byte, []byte, error)

Next returns the next key and value. Returns io.EOF error when done.

func (*Iterator) Progress

func (it *Iterator) Progress() float64

type Option

type Option func(*config)

func BurstRate

func BurstRate(burstRate uint64) Option

BurstRate specifies how much data can accumulate in memory, at a rate faster than can be flushed, before causing a synchronous flush.

func FileCacheSize

func FileCacheSize(size int) Option

FileCacheSize is the number of open files the index file cache may keep.

func GCInterval

func GCInterval(gcInterval time.Duration) Option

GCInterval is the amount of time to wait between GC cycles. A value of 0 disables garbage collection.

func GCTimeLimit

func GCTimeLimit(gcTimeLimit time.Duration) Option

GCTimeLimit is the maximum amount of time that a GC cycle may run.

func IndexBitSize

func IndexBitSize(indexBitSize uint8) Option

IndexBitSize is the number of bits in an index prefix.

func IndexFileSize

func IndexFileSize(indexFileSize uint32) Option

IndexFileSize is the maximum offset an index record can have within an individual index file, before the record must be stored in another file.

func PrimaryFileSize

func PrimaryFileSize(fileSize uint32) Option

PrimaryFileSize is the maximum offset a primary record can have within an individual primary file, before the record must be stored in another file.

func SyncInterval

func SyncInterval(syncInterval time.Duration) Option

SyncInterval determines how frequently changes are flushed to disk.

func SyncOnFlush

func SyncOnFlush(syncOnFlush bool) Option

SyncOnFlush, when set to true, causes fsync to be called as part of Flush.

type Store

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

func OpenStore

func OpenStore(ctx context.Context, primaryType string, dataPath, indexPath string, options ...Option) (*Store, error)

OpenStore opens the index and returns a Store with the specified primary type.

Calling Store.Close closes the primary and freelist.

func (*Store) Close

func (s *Store) Close() error

Close stops store goroutines and calls Close on the index, primary, and freelist. This flushes any outstanding work and buffered data to their files.

func (*Store) Err

func (s *Store) Err() error

func (*Store) Flush

func (s *Store) Flush() error

Flush writes outstanding work and buffered data to the primary, index, and freelist files. It then syncs these files to permanent storage.

func (*Store) FreelistStorageSize

func (s *Store) FreelistStorageSize() (int64, error)

FreelistStorageSize returns the storage used by the freelist files.

func (*Store) Get

func (s *Store) Get(key []byte) ([]byte, bool, error)

func (*Store) GetSize

func (s *Store) GetSize(key []byte) (types.Size, bool, error)

func (*Store) Has

func (s *Store) Has(key []byte) (bool, error)

func (*Store) Index

func (s *Store) Index() *index.Index

func (*Store) IndexStorageSize

func (s *Store) IndexStorageSize() (int64, error)

IndexStorageSize returns the storage used by the index files.

func (*Store) NewIterator

func (s *Store) NewIterator() *Iterator

NewIterator creates a new store iterator.

func (*Store) Primary

func (s *Store) Primary() primary.PrimaryStorage

func (*Store) PrimaryStorageSize

func (s *Store) PrimaryStorageSize() (int64, error)

PrimaryStorageSize returns the storage used by the primary storage files.

func (*Store) Put

func (s *Store) Put(key []byte, newValue []byte) error

func (*Store) Remove

func (s *Store) Remove(key []byte) (bool, error)

func (*Store) SetFileCacheSize

func (s *Store) SetFileCacheSize(size int)

func (*Store) SetReturnErrorOnDuplicatePut

func (s *Store) SetReturnErrorOnDuplicatePut(yes bool)

SetReturnErrorOnDuplicatePut sets whether to return an error when a duplicate key is inserted.

func (*Store) Start

func (s *Store) Start()

func (*Store) StorageSize

func (s *Store) StorageSize() (int64, error)

StorageSize returns the storage used by the index, primary, and freelist files.

Directories

Path Synopsis
Package filecache provides an LRU cache of opened files.
Package filecache provides an LRU cache of opened files.

Jump to

Keyboard shortcuts

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