storage

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTxnReadOnly is returned when the transaction is read only.
	ErrTxnReadOnly error = errors.New("transaction is read only")
)

Functions

This section is empty.

Types

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() (err 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(write 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 MemStore added in v0.11.0

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

func NewMemStore added in v0.11.0

func NewMemStore(cfg *MemStoreConfig) *MemStore

func (*MemStore) Close added in v0.11.0

func (m *MemStore) Close() error

func (*MemStore) Connect added in v0.11.0

func (m *MemStore) Connect() error

func (*MemStore) Delete added in v0.11.0

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

func (*MemStore) Get added in v0.11.0

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

func (*MemStore) GetPrefix added in v0.11.0

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

func (*MemStore) IterateTxnPrefix added in v0.11.0

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

func (*MemStore) IterateValuesPrefix added in v0.11.0

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

func (*MemStore) Set added in v0.11.0

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

func (*MemStore) Txn added in v0.11.0

func (m *MemStore) Txn(write bool, fn func(StorageTxn) error) error

type MemStoreConfig added in v0.11.0

type MemStoreConfig struct {
	Logger *zap.Logger
}

type MemStoreTxn added in v0.11.0

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

func (*MemStoreTxn) Delete added in v0.11.0

func (t *MemStoreTxn) Delete(key string) error

func (*MemStoreTxn) Get added in v0.11.0

func (t *MemStoreTxn) Get(key string) ([]byte, error)

func (*MemStoreTxn) GetPrefix added in v0.11.0

func (t *MemStoreTxn) GetPrefix(prefix string, offset int, limit int) ([]*KeyValue, error)

func (*MemStoreTxn) IterateTxnPrefix added in v0.11.0

func (t *MemStoreTxn) IterateTxnPrefix(prefix string, fn func(txn StorageTxn, key string) error) error

func (*MemStoreTxn) IterateValuesPrefix added in v0.11.0

func (t *MemStoreTxn) IterateValuesPrefix(prefix string, fn func(key string, val []byte) error) error

func (*MemStoreTxn) Set added in v0.11.0

func (t *MemStoreTxn) Set(key string, value []byte) error

type Storage

type Storage interface {
	StorageTxn
	Txn(write bool, fn func(txn StorageTxn) error) error
	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