store

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Apache-2.0, MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Primary types
	MultihashPrimary = "multihash"
	CIDPrimary       = "CID"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator added in v0.3.0

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 added in v0.3.0

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

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

func (*Iterator) Progress added in v0.3.7

func (it *Iterator) Progress() float64

type Option added in v0.2.0

type Option func(*config)

func BurstRate added in v0.2.0

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 added in v0.2.8

func FileCacheSize(size int) Option

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

func GCInterval added in v0.2.0

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 added in v0.2.0

func GCTimeLimit(gcTimeLimit time.Duration) Option

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

func IndexBitSize added in v0.2.0

func IndexBitSize(indexBitSize uint8) Option

IndexBitSize is the number of bits in an index prefix.

func IndexFileSize added in v0.2.0

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 added in v0.3.0

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 added in v0.2.0

func SyncInterval(syncInterval time.Duration) Option

SyncInterval determines how frequently changes are flushed to disk.

func SyncOnFlush added in v0.3.6

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, immutable bool, 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 added in v0.2.0

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 added in v0.3.0

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

func (*Store) IndexStorageSize added in v0.1.0

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

IndexStorageSize returns the storage used by the index files.

func (*Store) NewIterator added in v0.3.0

func (s *Store) NewIterator() *Iterator

NewIterator creates a new store iterator.

func (*Store) Primary added in v0.3.0

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

func (*Store) PrimaryStorageSize added in v0.2.0

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, value []byte) error

func (*Store) Remove

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

func (*Store) SetFileCacheSize added in v0.2.8

func (s *Store) SetFileCacheSize(size int)

func (*Store) Start

func (s *Store) Start()

func (*Store) StorageSize added in v0.2.0

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.
cid

Jump to

Keyboard shortcuts

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