storage

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStoreLocked is returned when the storage is locked.
	ErrStoreLocked error = errors.New("storage is locked")
	// ErrKeyNotFound is returned when the key is not found.
	ErrKeyNotFound error = errors.New("key not found")
	// ErrTxnReadOnly is returned when the transaction is read only.
	ErrTxnReadOnly error = errors.New("transaction is read only")
)

Functions

This section is empty.

Types

type DebugStore added in v0.8.0

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

func NewDebugStore added in v0.8.0

func NewDebugStore(cfg *DebugStoreConfig) *DebugStore

func (*DebugStore) Close added in v0.8.0

func (m *DebugStore) Close() error

func (*DebugStore) Connect added in v0.8.0

func (m *DebugStore) Connect() error

func (*DebugStore) Delete added in v0.8.0

func (m *DebugStore) Delete(key string) error

func (*DebugStore) Get added in v0.8.0

func (m *DebugStore) Get(key string) ([]byte, error)

func (*DebugStore) GetPrefix added in v0.8.0

func (m *DebugStore) GetPrefix(prefix string, offset, limit int) ([]*KeyValue, error)

func (*DebugStore) IterateTxnPrefix added in v0.8.0

func (m *DebugStore) IterateTxnPrefix(prefix string, fn func(StorageTxn, string) error) error

func (*DebugStore) IterateValuesPrefix added in v0.8.0

func (m *DebugStore) IterateValuesPrefix(prefix string, fn func(string, []byte) error) error

func (*DebugStore) Set added in v0.8.0

func (m *DebugStore) Set(key string, value []byte) error

type DebugStoreConfig added in v0.8.0

type DebugStoreConfig struct {
	Logger *zap.Logger
}

type FileStore

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

func NewFileStore

func NewFileStore(fsConfig *FileStoreConfig) *FileStore

func (*FileStore) Close

func (s *FileStore) Close() error

func (*FileStore) Connect

func (s *FileStore) Connect() error

func (*FileStore) Delete

func (s *FileStore) Delete(key string) error

func (*FileStore) Get

func (s *FileStore) Get(key string) ([]byte, error)

func (*FileStore) GetPrefix

func (s *FileStore) GetPrefix(prefix string, offset, limit int) ([]*KeyValue, error)

func (*FileStore) IterateTxnPrefix

func (s *FileStore) IterateTxnPrefix(prefix string, fn func(StorageTxn, string) error) error

func (*FileStore) IterateValuesPrefix

func (s *FileStore) IterateValuesPrefix(prefix string, fn func(string, []byte) error) error

func (*FileStore) Set

func (s *FileStore) Set(key string, value []byte) error

func (*FileStore) Txn

func (s *FileStore) Txn(readOnly bool, fn func(StorageTxn) error) error

type FileStoreConfig

type FileStoreConfig struct {
	Directory string `koanf:"dir"`
	Logger    *zap.Logger
}

type FileStoreTxn

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

func (*FileStoreTxn) Delete

func (tx *FileStoreTxn) Delete(key string) error

func (*FileStoreTxn) Get

func (tx *FileStoreTxn) Get(key string) ([]byte, error)

func (*FileStoreTxn) GetPrefix

func (s *FileStoreTxn) GetPrefix(prefix string, offset, limit int) ([]*KeyValue, error)

func (*FileStoreTxn) IterateTxnPrefix

func (tx *FileStoreTxn) IterateTxnPrefix(prefix string, fn func(StorageTxn, string) error) error

func (*FileStoreTxn) IterateValuesPrefix

func (tx *FileStoreTxn) IterateValuesPrefix(prefix string, fn func(string, []byte) error) error

func (*FileStoreTxn) Set

func (tx *FileStoreTxn) Set(key string, value []byte) error

type KeyValue

type KeyValue struct {
	Key   string
	Value []byte
}

type MemoryStore

type MemoryStore struct {
	*FileStore
}

func NewMemoryStore

func NewMemoryStore(cfg *MemoryStoreConfig) *MemoryStore

type MemoryStoreConfig

type MemoryStoreConfig struct {
	// Path to the directory where the files will be stored.
	// If the directory does not exist, it will be created.
	// If the directory exists, it will be used.
	Logger *zap.Logger
}

type Storage

type Storage interface {
	StorageTxn
	Connect() error
	Close() error
}

type StorageTxn

type StorageTxn interface {
	Get(string) ([]byte, error)
	Set(string, []byte) error
	IterateValuesPrefix(prefix string, fn func(key string, val []byte) error) error
	IterateTxnPrefix(prefix string, fn func(txn StorageTxn, key string) error) error
	GetPrefix(prefix string, offset, limit int) ([]*KeyValue, error)
	Delete(string) error
}

Jump to

Keyboard shortcuts

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